Part Number Hot Search : 
CSBUNG00 MC330 BTS120 LM336BAP MAX16 C1206 FM107 ZITE13F
Product Description
Full Text Search
 

To Download ADE7566 Datasheet File

  If you can't view the Datasheet, Please click here to try to view without PDF Reader .  
 
 


  Datasheet File OCR Text:
  single-phase energy measurement ic with 8052 mcu, rtc, and lcd driver ADE7566/ade7569/ade7166/ade7169 rev. a information furnished by analog devices is believed to be accurate and reliable. however, no responsibility is assumed by analog devices for its use, nor for any infringements of patents or other rights of third parties that may result from its use. specifications subject to change without notice. no license is granted by implication or otherwise under any patent or patent rights of analog devices. trademarks and registered trademarks are the property of their respective owners. one technology way, p.o. box 9106, norwood, ma 02062-9106, u.s.a. tel: 781.329.4700 www.analog.com fax: 781.461.3113 ? 2007 analog devices, inc. all rights reserved. general features wide supply voltage operation: 2.4 v to 3.7 v internal bipolar switch between regulated and battery inputs ultralow power operation with power-saving modes (psm) full operation: 4 ma to 1.6 ma (pll clock dependent) battery mode: 3.2 ma to 400 a (pll clock dependent) sleep mode real-time clock (rtc) mode: 1.5 a rtc and lcd mode: 27 a (lcd charge pump enabled) reference: 1.2 v 0.1% (10 ppm/c drift) 64-lead rohs package options lead frame chip scale package (lfcsp) low profile quad flat package (lqfp) operating temperature range: ?40c to +85c energy measurement features proprietary analog-to-digital converters (adcs) and digital signal processing (dsp) provide high accuracy active (watt), reactive (var), and apparent energy (va) measurement less than 0.1% error on active energy over a dynamic range of 1000 to 1 @ 25c less than 0.5% error on reactive energy over a dynamic range of 1000 to 1 @ 25c (ade7569 and ade7169 only) less than 0.5% error on root mean square (rms) measurements over a dynamic range of 500 to 1 for current (i rms ) and 100 to 1 for voltage (v rms ) @ 25c supports iec 62053-21, iec 62053-22, iec 62053-23, en 50470-3 class a, class b, and class c, and ansi c12-16 differential input with programmable gain amplifiers (pgas) supports shunts, current transformers, and di/dt current sensors (ade7569 and ade7169 only) two current inputs for antitamper detection in the ade7166/ade7169 high frequency outputs proportional to i rms , active, reactive, or apparent power (ap) table 1. part no. anti- tamper watt, va, i rms , v rms var di/dt sensor ADE7566 no yes no no ade7569 no yes yes yes ade7166 yes yes no no ade7169 yes yes yes yes microprocessor features 8052-based core single-cycle 4 mips 8052 core 8052-compatible instruction set 32.768 khz external crystal with on-chip pll two external interrupt sources external reset pin low power battery mode wake-up from i/o, temperature change, alarm, and universal asynchronous receiver/transmitter (uart) lcd driver operation temperature measurement real-time clock counter for seconds, minutes, and hours automatic battery switchover for rtc backup operation down to 2.4 v ultralow battery supply current: 1.5 a selectable output frequency: 1 hz to 16.384 khz embedded digital crystal frequency compensation for calibration and temperature variation 2 ppm resolution integrated lcd driver 108-segment driver for the ADE7566/ade7569 and 104-segment driver for the ade7166/ade7169 2, 3, or 4 multiplexing lcd voltages generated internally or with external resistors internal adjustable drive voltages up to 5 v independent of power supply level on-chip peripherals uart, spi or i 2 c, and watchdog timer power supply monitoring with user-selectable levels memory: 16 kb flash memory, 512 bytes ram development tools single-pin emulation ide-based assembly and c-source debugging
ADE7566/ade7569/ade7166/ade7169 rev. a | page 2 of 144 table of contents general features ............................................................................... 1 energy measurement features........................................................ 1 microprocessor features.................................................................. 1 revision history ............................................................................... 3 general description ......................................................................... 4 functional block diagrams............................................................. 4 specifications..................................................................................... 6 energy metering ........................................................................... 6 analog peripherals ....................................................................... 7 digital interface ............................................................................ 8 timing specifications ................................................................ 10 absolute maximum ratings.......................................................... 15 thermal resistance .................................................................... 15 esd caution................................................................................ 15 pin configuration and function descriptions........................... 16 typical performance characteristics ........................................... 18 terminology .................................................................................... 22 sfr mapping ................................................................................... 23 power management........................................................................ 25 power management register details ....................................... 25 power supply architecture........................................................ 28 battery switchover...................................................................... 28 power supply monitor interrupt (psm).................................. 29 using the power supply features ............................................. 31 operating modes ............................................................................ 33 psm0 (normal mode) ............................................................... 33 psm1 (battery mode) ................................................................ 33 psm2 (sleep mode).................................................................... 33 3.3 v peripherals and wake-up events................................... 34 transitioning between operating modes ............................... 35 using the power management features .................................. 35 energy measurement ..................................................................... 37 access to energy measurement sfrs ...................................... 37 access to internal energy measurement registers................ 37 energy measurement registers ................................................ 40 energy measurement internal registers details.................... 41 interrupt status/enable sfrs .................................................... 44 analog inputs.............................................................................. 46 analog-to-digital conversion.................................................. 47 fault detection ........................................................................... 50 di/dt current sensor and digital integrator for the ade7569/ade7169................................................................... 51 power quality measurements................................................... 53 phase compensation ................................................................. 55 rms calculation ........................................................................ 55 active power calculation .......................................................... 58 active energy calculation ........................................................ 60 reactive power calculation for the ade7569/ade7169..... 63 reactive energy calculation for the ade7569/ade7169 ... 64 apparent power calculation..................................................... 68 apparent energy calculation ................................................... 69 ampere-hour accumulation ................................................... 70 energy-to-frequency conversion............................................ 71 energy register scaling ............................................................. 72 energy measurement interrupts .............................................. 72 temperature, battery, and supply voltage measurements........ 73 temperature measurement ....................................................... 75 battery measurement................................................................. 75 external voltage measurement ................................................ 76 8052 mcu core architecture.................................................... 78 mcu registers............................................................................ 78 basic 8052 registers ................................................................... 80 standard 8052 sfrs.................................................................... 81 memory overview ..................................................................... 81 addressing modes...................................................................... 82 instruction set ............................................................................ 84 read-modify-write instructions ............................................. 86 instructions that affect flags .................................................. 86 dual data pointers ......................................................................... 88 interrupt system ............................................................................. 89 standard 8052 interrupt architecture ..................................... 89 interrupt architecture ............................................................... 89 interrupt registers...................................................................... 89 interrupt priority........................................................................ 90 interrupt flags ............................................................................ 91 interrupt vectors ........................................................................ 93 interrupt latency........................................................................ 93 context saving............................................................................ 93 watchdog timer ............................................................................. 94 lcd driver...................................................................................... 96
ADE7566/ade7569/ade7166/ade7169 rev. a | page 3 of 144 lcd registers ..............................................................................96 lcd setup ....................................................................................99 lcd timing and waveforms ....................................................99 blink mode................................................................................ 100 display element control......................................................... 100 voltage generation .................................................................. 101 lcd external circuitry........................................................... 101 lcd function in psm2........................................................... 101 flash memory ............................................................................... 103 overview ................................................................................... 103 flash memory organization................................................... 104 using the flash memory ......................................................... 104 protecting the flash memory ................................................. 107 in-circuit programming ......................................................... 108 timers ............................................................................................ 109 timer registers......................................................................... 109 timer 0 and timer 1................................................................ 111 timer 2 ...................................................................................... 112 pll ................................................................................................. 114 pll registers ............................................................................ 114 real-time clock........................................................................... 116 rtc registers ........................................................................... 116 read and write operations .................................................... 119 rtc modes ............................................................................... 119 rtc interrupts ......................................................................... 119 rtc calibration ....................................................................... 120 uart serial interface...................................................................121 uart registers .........................................................................121 uart operation modes ..........................................................124 uart baud rate generation ..................................................125 uart additional features ......................................................127 serial peripheral interface (spi)..................................................128 spi registers ..............................................................................128 spi pins.......................................................................................131 spi master operating modes ..................................................132 spi interrupt and status flags .................................................133 i 2 c compatible interface..............................................................134 serial clock generation ...........................................................134 slave addresses..........................................................................134 i 2 c registers...............................................................................134 read and write operations .....................................................135 i 2 c receive and transmit fifos.............................................136 i/o ports .........................................................................................137 parallel i/o.................................................................................137 i/o registers ..............................................................................138 port 0...........................................................................................141 port 1...........................................................................................141 port 2...........................................................................................141 determining the version of the ADE7566/ade7569..............142 outline dimensions......................................................................143 ordering guide .........................................................................144 revision history revision history: ADE7566/ade7569/ade7166/ade7169 12/07revision a: initial combined version revision history: ADE7566/ade7569 12/07rev 0 to rev a added ade7166/ade7169 .............................................. universal changes to table 1 ............................................................................1 changes to ordering guide.........................................................144 11/07revision 0: initial version
ADE7566/ade7569/ade7166/ade7169 rev. a | page 4 of 144 general description the ADE7566/ade7569/ade7166/ade7169 1 integrate analog devices, inc., energy (ade) metering ic analog front end and fixed function dsp solution with an enhanced 8052 mcu core, an rtc, an lcd driver, and all the peripherals to make an electronic energy meter with an lcd display in a single part. such as sag, peak, and zero crossing are included in the energy measurement dsp to simplify energy meter design. the microprocessor functionality includes a single-cycle 8052 core, a real-time clock with a power supply backup pin, a uart, and an spi or i 2 c? interface. the ready-to-use information from the ade core reduces the program memory size requirement, making it easy to integrate complicated design into 16 kb of flash memory. the ade measurement core includes active, reactive, and apparent energy calculations, as well as voltage and current rms measure- ments. this information is ready to use for energy billing by using built-in energy scalars. many power line supervisory features the ADE7566/ade7569/ade7166/ade7169 also include a 108-/104-segment lcd driver. this driver generates voltages capable of driving lcds up to 5 v. 1 patents pending. functional block diagrams i p i n v p v n r e f i n / o u t energy measurement dsp osc com0 ... ... com3 . . . c f 1 c f 2 ldo 3v/5v lcd charge pump single cycle 8052 mcu ADE7566/ade7569 fp26 v d c i n v bat v d d v s w o u t v i n t d v i n t a r e s e t dgnd a gnd t x d uart serial port lcdva lcdvb lcdvc . . . fp0 fp15 rtc s s s c l k m i s o m o s i / s d a t a r x d s d e n t 2 t 2 e x t 0 t 1 lcdvp1 lcdvp2 x t a l 2 x t a l 1 i n t 0 i n t 1 fp16 fp17 fp23 fp22 fp21 fp20 fp19 fp18 fp25 fp24 p 0 . 7 ( s s / t 1 ) p 0 . 6 ( s c l k / t 0 ) p 0 . 5 ( m i s o ) p 0 . 4 ( m o s i / s d a t a ) p 0 . 0 ( b c t r l / i n t 1 ) p 1 . 0 ( r x d ) p 1 . 1 ( t x d ) p 1 . 2 ( f p 2 5 ) p 1 . 3 ( t 2 e x / f p 2 4 ) p 1 . 6 ( f p 2 1 ) p 1 . 7 ( f p 2 0 ) p 1 . 4 ( t 2 / f p 2 3 ) p 1 . 5 ( f p 2 2 ) p2.0 (fp18) p2.1 (fp17) p2.2 (fp16) p2.3 (sden) p 0 . 1 ( f p 1 9 ) p 0 . 2 ( c f 1 , r t c c a l ) p 0 . 3 ( c f 2 ) 1.20v ref 52 53 55 49 50 63 54 58 64 61 60 62 56 51 44 36 37 46 47 48 45 5 6 7 8 9 10 11 12 13 14 20 35 1 4 15 17 18 16 19 44 14 13 12 57 43 42 39 38 7 6 45 11 43 42 41 40 39 38 37 36 5 6 7 8 9 10 38 39 40 41 59 pga2 ? + pga1 ? + adc adc temp adc vdcin adc program memory 16kb flash power supply control and monitoring user ram 256 bytes user xram 256 bytes temp sensor battery adc spi/i 2 c serial interface 3 16-bit counter timers 108-segment lcd driver watchdog timer downloader debugger pll 1-pin emulator ldo ea uart timer por 06353-001 figure 1. ADE7566/ade7569 functional block diagram
ADE7566/ade7569/ade7166/ade7169 rev. a | page 5 of 144 adc i pa i n i pb ref i n / o u t energy measurement dsp osc com0 ... ... com3 . . . cf1 cf2 ldo 3v/5v lcd charge pump single cycle 8052 mcu ade7166/ade7169 v d c i n v bat v d d v s w o u t v i n t d v i n t a reset dgnd a gnd txd uart serial port lcdva lcdvb lcdvc . . . fp0 fp15 rtc ss sclk miso mo si/sdata rxd sden t2 t2ex t0 t1 lcdvp1 lcdvp2 xta l2 x tal1 int0 int1 fp16 fp17 fp23 fp22 fp21 fp20 fp19 fp18 fp25 fp24 p0. 7 (ss/t1) p0.6 (sclk/t0) p0. 5 (miso) p0 .4 (mosi/sd ata) p0. 0 (bctrl/in t1) p1.0 (rxd ) p1.1 (txd) p 1.2 (fp25) p 1.3 (t2ex/f p24) p1.6 (fp2 1) p1.7 (fp20) p1.4 (t 2/fp23) p 1.5 (fp22) p2.0 (fp18) p2.1 (fp17) p2.2 (fp16) p2.3 (sden) p0 .1 (fp19) p0 .2 (cf1, rtc cal) p 0.3 (cf2) 1.20v ref 52 53 55 v p v n 49 63 54 58 64 61 60 62 56 51 44 36 37 46 47 48 45 5 6 7 8 9 10 11 12 13 14 20 35 1 4 15 17 18 16 19 44 14 13 12 57 43 42 39 38 7 8 45 11 43 42 41 40 39 38 37 36 5 6 7 8 9 10 38 39 40 41 59 pga1 ? + adc 50 pga2 ? + pga1 ? + adc temp adc vdcin adc program memory 16kb flash power supply control and monitoring user ram 256 bytes user xram 256 bytes temp sensor battery adc spi/i 2 c serial interface 3 16-bit counter timers 108-segment lcd driver watchdog timer downloader debugger pll 1-pin emulator ldo ea uart timer por 06353-119 figure 2. ade7166/ade7169 functional block diagram
ADE7566/ade7569/ade7166/ade7169 rev. a | page 6 of 144 specifications v dd = 3.3 v 5%, agnd = dgnd = 0 v, on-chip reference xtal = 32.768 khz, t min to t max = ?40c to +85c, unless otherwise noted. energy metering table 2. parameter min typ max unit test conditions/comments measurement accuracy 1 phase error between channels pf = 0.8 capacitive 0.05 degrees phase lead 37 pf = 0.5 inductive 0.05 degrees phase lag 60 active energy measurement error 2 0.1 % of reading over a dynamic range of 1000 to 1 @ 25c ac power supply rejection 2 v dd = 3.3 v + 100 mv rms/120 hz output frequency variation 0.01 % i px = v p = 100 mv rms dc power supply rejection 2 v dd = 3.3 v 117 mv dc output frequency variation 0.01 % active energy measurement bandwidth 1 8 khz reactive energy measurement error 2 , 3 0.5 % of reading over a dynamic range of 1000 to 1 @ 25c v rms measurement error 2 0.5 % of reading over a dynamic range of 100 to 1 @ 25c v rms measurement bandwidth 1 3.9 khz i rms measurement error 2 0.5 % of reading over a dynamic range of 500 to 1 @ 25c i rms measurement bandwidth 1 3.9 khz analog inputs maximum signal levels 400 mv peak v p ? v n differential input ADE7566/ade7569 400 mv peak i p ? i n differential input ade7166/ade7169 250 mv peak i pa ? i n and i pb ? i n differential inputs input impedance (dc) 770 k adc offset error 2 10 mv pga1 = pga2 = 1 1 mv pga1 = 16 gain error 2 current channel ?3 + 3 % i pa = i pb = 0.4 v dc or i p = 0.4 dc voltage channel ?3 + 3 % voltage channel = 0.4 v dc gain error match 0.2 % cf1 and cf2 pulse output maximum output frequency 13.5 khz v p ? v n = 400 mv peak; i pa ? i n = 250 mv pga1 = 2 sine wave duty cycle 50 % if cf1 or cf2 frequency, >5.55 hz active high pulse width 90 ms if cf1 or cf2 frequency, <5.55 hz fault detec tion 4 fault detection threshold inactive input active input 6.25 %, of active i pa or i pb active input swap threshold inactive input > active input 6.25 % of active i pa or i pb active accuracy fault mode operation i pa active, i pb = agnd 0.1 % of reading over a dynamic range of 500 to 1 ipb active, i pa = agnd 0.1 % of reading over a dynamic range of 500 to 1 fault detection delay 3 seconds swap delay 3 seconds 1 these numbers are not production tested but are guaranteed by design and/or characterization data on production release. 2 see the terminology section for definition. 3 this function is not available in the ADE7566 and the ade7166. 4 this function is not available in the ADE7566 and the ade7569.
ADE7566/ade7569/ade7166/ade7169 rev. a | page 7 of 144 analog peripherals table 3. parameter min typ max unit test conditions/comments internal adcs (battery, temperature, v dcin ) power supply operating range 2.4 3.7 v measured on v swout no missing codes 1 8 bits conversion delay 2 38 s adc gain v dcin measurement 15.3 mv/lsb v bat measurement 14.6 mv/lsb temperature measurement 0.78 c/lsb adc offset v dcin measurement at 3 v 206 lsb v bat measurement at 3.7 v 205 lsb temperature measurement at 25c 129 lsb v dcin analog input maximum signal levels 0 3.3 v input impedance (dc) 1 m low v dcin detection threshold 1.09 1.2 1.27 v power-on reset (por) v dd por detection threshold 2.5 2.95 v por active timeout period 33 ms v swout por detection threshold 1.8 2.2 v por active timeout period 20 ms v intd por detection threshold 2.03 2.22 v por active timeout period 16 ms v inta por detection threshold 2.05 2.15 v por active timeout period 120 ms battery switch over voltage operating range (v swout ) 2.4 3.7 v v dd to v bat switching switching threshold (v dd ) 2.5 2.95 v switching delay 10 ns when v dd to v bat switch activated by v dd 30 ms when v dd to v bat switch activated by v dcin v bat to v dd switching switching threshold (v dd ) 2.5 2.95 v switching delay 30 ms based on v dd > 2.75 v v swout to v bat leakage current 10 na v bat = 0 v, v swout = 3.43 v, t a = 25c lcd, charge pump active charge pump capacitance between lcdvp1 and lcdvp2 100 nf lcdva, lcdvb, lcdvc decoupling capacitance 470 nf lcdva 0 1.75 v lcdvb 0 3.5 v 1/3 bias mode lcdvc 0 5.3 v 1/3 bias mode v1 segment line voltage lcdva ? 0.1 lcdva v current on segment line = ?2 a v2 segment line voltage lcdvb ? 0.1 lcdvb v current on segment line = ?2 a v3 segment line voltage lcdvc ? 0.1 lcdvc v current on segment line = ?2 a dc voltage across segment and com pin 50 mv lcdvc ? lcdvb, lcdvc ? lcdva, or lcdvb ? lcdva
ADE7566/ade7569/ade7166/ade7169 rev. a | page 8 of 144 parameter min typ max unit test conditions/comments lcd, resistor ladder active leakage current 20 na 1/2 and 1/3 bias modes, no load v1 segment line voltage lcdva ? 0.1 lcdva v current on segment line = ?2 a v2 segment line voltage lcdvb ? 0.1 lcdvb v current on segment line = ?2 a v3 segment line voltage lcdvc ? 0.1 lcdvc v current on segment line = ?2 a on-chip reference reference error 0.9 mv t a = 25c power supply rejection 80 db temperature coefficient 1 10 50 ppm/c 1 these numbers are not production tested but are guaranteed by design and/or characterization data on production release. 2 delay between adc conversion request and interrupt set. digital interface table 4. parameter min typ max unit test conditions/comments logic inputs all inputs except xtal1, xtal2, bctrl, int0 , int1 , reset input high voltage, v inh 2.0 v input low voltage, v inl 0.4 v bctrl, int0 , int1 , reset input high voltage, v inh 1.3 v input low voltage, v inl 0.4 v input currents reset 100 na reset = v swout = 3.3 v port 0, port 1, port 2 100 na internal pull-up disabled, input = 0 v or v swout ?3.75 ?8.5 a internal pull-up enabled, input = 0 v, v swout = 3.3 v input capacitance 10 pf all digital inputs flash memory endurance 1 10,000 cycles data retention 2 20 years t j = 85c crystal oscillator crystal equivalent series resistance 30 50 k crystal frequency 32 32.768 33.5 khz xtal1 input capacitance 12 pf xtal2 output capacitance 12 pf mcu clock rate (f core ) 4.096 mhz crystal = 32.768 khz and cd[2:0] = 0 32 khz crystal = 32.768 khz and cd[2:0] = 0b111 logic outputs output high voltage, v oh 2.4 v v dd = 3.3 v 5% i source 80 a output low voltage, v ol 3 0.4 v v dd = 3.3 v 5% i sink 2 ma start-up time 4 psm0 power-on time 448 ms v dd at 2.75 v to psm0 code execution from power saving mode 1 (psm1) psm1 psm0 130 ms v dd at 2.75 v to psm0 code execution from power saving mode 2 (psm2) psm2 psm1 48 ms wake-up event to psm1 code execution psm2 psm0 186 ms v dd at 2.75 v to psm0 code execution
ADE7566/ade7569/ade7166/ade7169 rev. a | page 9 of 144 parameter min typ max unit test conditions/comments power supply inputs v dd 3.13 3.3 3.46 v v bat 2.4 3.3 3.7 v internal power supply switch (v swout ) v bat to v swout on resistance 22 v bat = 2.4 v v dd to v swout on resistance 10.2 v dd = 3.13 v v bat v dd switching open time 40 ns bctrl state change and switch delay 18 s v swout output current drive 1 6 ma power supply outputs v inta 2.25 2.75 v v intd 2.3 2.70 v v inta power supply rejection 60 db v intd power supply rejection 50 db power supply currents current in normal mode (psm0) 4 5.3 ma f core = 4.096 mhz, lcd and meter active 2.1 ma f core = 1.024 mhz, lcd and meter active 1.6 ma f core = 32.768 khz, lcd and meter active 3.2 4.25 ma f core = 4.096 mhz, meter dsp active, metering adc powered down 3 3.9 ma f core = 4.096 mhz, metering adc and dsp powered down current in psm1 3.2 5.05 ma f core = 4.096 mhz, lcd active, v bat = 3.7 v 880 a f core = 1.024 mhz, lcd active current in psm2 38 a lcd active with charge pump at 3.3 v + rtc 1.5 a rtc only, t a = 25c, v bat = 3.3 v power supply currents current in normal mode (psm0) 4 5.3 ma f core = 4.096 mhz, lcd and meter active 1 endurance is qualified as per jedec standard 22 method a117 and measured at ?40c, +25c, +85c, and +125c. 2 retention lifetime equivalent at junction temperature (t j ) = 85c as per jedec standard 22 method a117. retention lifetime derates with junction temperature. 3 test carried out with all the i/os set to a low output level. 4 delay between power supply valid and exec ution of first instruction by 8052 core.
ADE7566/ade7569/ade7166/ade7169 rev. a | page 10 of 144 timing specifications ac inputs during testing were driven at v swout ? 0.5 v for logic 1 and 0.45 v for logic 0. timing measurements were made at v ih minimum for logic 1 and v il maximum for logic 0, as shown in figure 3 . for timing purposes, a port pin is no longer floating when a 100 mv change from load voltage occurs. a port pin begins to float when a 100 mv change from the loaded v oh /v ol level occurs as shown in figure 3 . c load for all outputs = 80 pf, unless otherwise noted. v dd = 2.7 v to 3.6 v; all specifications t min to t max , unless otherwise noted. v swout ? 0.5 v 0.45v 0.2v swout + 0.9v test points 0.2v swout ? 0.1v v load ? 0.1v v load v load + 0.1v timing reference points v load ? 0.1v v load v load ? 0.1v 06353-002 figure 3. timing waveform characteristics table 5. clock input (external clock driven xtal1) parameter 32.768 khz external crystal parameter description min typ max unit t ck xtal1 period 30.52 s t ckl xtal1 width low 6.26 s t ckh xtal1 width high 6.26 s t ckr xtal1 rise time 9 ns t ckf xtal1 fall time 9 ns 1/t core core clock frequency 0.032768 1.024 4.096 mhz 1 1 the ADE7566/ade7569/ade7166/ade7169 i nternal pll locks o nto a multiple (512 times) of the 32.768 khz external crystal frequenc y to provide a stable 4.096 mhz internal clock for the system. the core can operate at this frequency or at a binary submultiple defined by the cd[2:0] bits, s elected via the powcon sfr (see table 25). table 6. i 2 c-compatible interface timi ng parameters (400 khz) parameter description typ unit t buf bus-free time between stop condition and start condition 1.3 s t l sclk low pulse width 1.36 s t h sclk high pulse width 1.14 s t shd start condition hold time 251.35 s t dsu data setup time 740 ns t dhd data hold time 400 ns t rsu setup time for repeated start 12.5 ns t psu stop condition setup time 400 ns t r rise time of both sclk and sdata 200 ns t f fall time of both sclk and sdata 300 ns t sup pulse width of spike suppressed 50 ns 1 1 input filtering on both the sclk and sdata inputs suppresses noise spikes less than 50 ns. msb t buf sdata (i/o) sclk (i) stop condition start condition repeated start lsb ack msb 1 2to 7 89 1 s(r) ps t psu t dsu t shd t dhd t sup t dsu t dhd t h t sup t l t rsu t r t r t f t f 0 6353-003 figure 4. i 2 c-compatible in terface timing
ADE7566/ade7569/ade7166/ade7169 rev. a | page 11 of 144 table 7. spi master mode timi ng (spicpha = 1) parameters parameter description min typ max unit t sl sclk low pulse width 2 spir t core ns 1 t sh sclk high pulse width 2 spir t core 1 ns t dav data output valid after sclk edge 3 t core 1 ns t dsu data input setup time be fore sclk edge 0 ns t dhd data input hold time after sclk edge t core 1 ns t df data output fall time 19 ns t dr data output rise time 19 ns t sr sclk rise time 19 ns t sf sclk fall time 19 ns 1 t core depends on the clock divider or cd bits of the powcon sfr (see table 25); t core = 2 cd /4.096 mhz. sclk (spicpol = 0) t dsu sclk (spicpol = 1) mosi miso msb lsb lsb in bits [6:1] bits [6:1] t dhd t dr t dav t df t sh t sl t sr t sf msb in 06353-004 figure 5. spi master mode timing (spicpha = 1)
ADE7566/ade7569/ade7166/ade7169 rev. a | page 12 of 144 table 8. spi master mode timi ng (spicpha = 0) parameters parameter description min typ max unit t sl sclk low pulse width 2 spir t core 1 (spir + 1) t core 1 ns t sh sclk high pulse width 2 spir t core 1 (spir + 1) t core 1 ns t dav data output valid after sclk edge 3 t core 1 ns t dosu data output setup before sclk edge 75 ns t dsu data input setup time be fore sclk edge 0 ns t dhd data input hold time after sclk edge t core 1 ns t df data output fall time 19 ns t dr data output rise time 19 ns t sr sclk rise time 19 ns t sf sclk fall time 19 ns 1 t core depends on the clock divider or cd bits of the powcon sfr (see table 25); t core = 2 cd /4.096 mhz. sclk (spicpol = 0) t dsu sclk (spicpol = 1) mosi miso msb lsb lsb in bits [6:1] bits [6:1] t dhd t dr t dav t df t dosu t sh t sl t sr t sf msb in 0 6353-005 figure 6. spi master mode timing (spicpha = 0)
ADE7566/ade7569/ade7166/ade7169 rev. a | page 13 of 144 table 9. spi slave mode timing (spicpha = 1) parameters parameter description min typ max unit t ss ss 145 ns to sclk edge t sl sclk low pulse width 6 t core 1 ns t sh sclk high pulse width 6 t core 1 ns t dav data output valid after sclk edge 25 ns t dsu data input setup time be fore sclk edge 0 ns t dhd data input hold time after sclk edge 2 t core 1 + 0.5 s s t df data output fall time 19 ns t dr data output rise time 19 ns t sr sclk rise time 19 ns t sf sclk fall time 19 ns t sfs ss 0 ns high after sclk edge 1 t core depends on the clock divider or cd bits of the powcon sfr (see table 25); t core = 2 cd /4.096 mhz. msb mosi bits [6:1] t dhd t dsu msb in lsb in bits [6:1] lsb t dr t df t dav miso t sl t sh t sr t sf t sfs t ss sclk (spicpol = 1) sclk (spicpol = 0) ss 06353-006 figure 7. spi slave mode timing (spicpha = 1)
ADE7566/ade7569/ade7166/ade7169 rev. a | page 14 of 144 table 10. spi slave mode timing (spicpha = 0) parameters parameter description min typ max unit t ss ss 145 ns to sclk edge t sl sclk low pulse width 6 t core 1 ns t sh sclk high pulse width 6 t core 1 ns t dav data output valid after sclk edge 25 ns t dsu data input setup time be fore sclk edge 0 ns t dhd data input hold time after sclk edge 2 t core 1 + 0.5 s s t df data output fall time 19 ns t dr data output rise time 19 ns t sr sclk rise time 19 ns t sf sclk fall time 19 ns t doss data output valid after ss 0 edge ns t sfs ss 0 ns high after sclk edge 1 t core depends on the clock divider or cd bits of the powcon sfr (see table 25); t core = 2 cd /4.096 mhz. msb mosi bits [6:1] t dhd t dsu lsb in bits [6:1] lsb t dr t df t dav miso t sr t sf t sfs t ss sclk (spicpol = 1) sclk (spicpol = 0) ss t sh t sl t doss msb in 06353-007 figure 8. spi slave mode timing (spicpha = 0)
ADE7566/ade7569/ade7166/ade7169 rev. a | page 15 of 144 absolute maximum ratings t a = 25c, unless otherwise noted. table 11. parameter rating stresses above those listed under absolute maximum ratings may cause permanent damage to the device. this is a stress rating only; functional operation of the device at these or any other conditions above those indicated in the operational section of this specification is not implied. exposure to absolute maximum rating conditions for extended periods may affect device reliability. v dd to dgnd ?0.3 v to +3.7 v v bat to dgnd ?0.3 v to +3.7 v v dcin to dgnd ?0.3 v to v swout + 0.3 v ?0.3 v to v swout + 0.3 v input lcd voltage to agnd, lcdva, lcdvb, lcdvc 1 thermal resistance ?2 v to +2 v analog input voltage to agnd, v p , v n , i pa , and i n ja is specified for the worst-case conditions, that is, a device soldered in a circuit board for surface-mount packages. digital input voltage to dgnd ?0.3 v to v swout + 0.3 v table 12. thermal resistance digital output voltage to dgnd ?0.3 v to v swout + 0.3 v operating temperature range (industrial) ?40c to +85c package type ja jc unit storage temperature range ?65c to +150c 64-lead lqfp 60 20.5 c/w 64-lead lqfp, power dissipation 64-lead lfcsp 27.1 2.3 c/w lead temperature soldering 300c esd caution time 30 sec 1 when used with external resistor divider.
ADE7566/ade7569/ade7166/ade7169 rev. a | page 16 of 144 pin configuration and fu nction descriptions 64 v dcin 63 dgnd 62 v intd 61 v swout 60 v dd 59 v inta 58 v bat 57 ref in/ou t 56 fp26/i pb 55 reset 54 agnd 53 i n 52 i pa 51 ea 50 v n 49 v p 47 xtal1 46 xtal2 45 bctrl/int1/p0.0 42 p0.3/cf2 43 p0.2/cf1/rtccal 44 sden/p2.3 48 int0 41 p0.4/mosi/sdata 40 p0.5/miso 39 p0.6/sclk/t0 37 p1.0/rxd 36 p1.1/txd 35 fp0 34 fp1 33 fp2 38 p0.7/ss/t1 2 com2/fp28 3 com1 4 com0 7 p1.4/t2/fp23 6 p1.3/t2ex/fp24 5 p1.2/fp25 1 com3/fp27 8 p1.5/fp22 9 p1.6/fp21 10 p1.7/fp20 12 p2.0/fp18 13 p2.1/fp17 14 p2.2/fp16 15 lcdvc 16 lcdvp2 11 p0.1/fp19 17 lcdvb 18 lcdva 19 lcdvp1 20 fp15 21 fp14 22 fp13 23 fp12 24 fp11 25 fp10 26 fp9 27 fp8 28 fp7 29 fp6 30 fp5 31 fp4 32 fp3 pin 1 ADE7566/ade7569/ade7166/ade7169 top view (not to scale) 06353-010 figure 9. pin configuration table 13. pin function descriptions pin no. mnemonic description 1 com3/fp27 common output 3 or lcd segment o utput 27. com3 is used for lcd backplane. 2 com2/fp28 common output 2 or lcd segment o utput 28. com2 is used for lcd backplane. 3 com1 common output 1. com1 is used for lcd backplane. 4 com0 common output 0. com0 is used for lcd backplane. 5 p1.2/fp25 general-purpose digital i/o port 1.2 or lcd segment output 25. 6 p1.3/t2ex/fp24 general-purpose digital i/o port 1.3, timer 2 control input, or lcd segment output 24. 7 p1.4/t2/fp23 general-purpose digital i/o port 1.4, timer 2 input, or lcd segment output 23. 8 p1.5/fp22 general-purpose digital i/o port 1.5 or lcd segment output 22. 9 p1.6/fp21 general-purpose digital i/o port 1.6 or lcd segment output 21. 10 p1.7/fp20 general-purpose digital i/o port 1.7 or lcd segment output 20. 11 p0.1/fp19 general-purpose digital i/o port 0.1 or lcd segment output 19. 12 p2.0/fp18 general-purpose digital i/o port 2.0 or lcd segment output 18. 13 p2.1/fp17 general-purpose digital i/o port 2.1 or lcd segment output 17. 14 p2.2/fp16 general-purpose digital i/o port 2.2 or lcd segment output 16. 15 lcdvc output port for lcd levels. this pin should be decoupled with a 470 nf capacitor. 16 lcdvp2 analog output. a 100 nf capacitor should be connected between this pin and lcdvp1 for the internal lcd charge pump device. 17, 18 lcdvb, lcdva output port for lcd levels. these pins should be decoupled with a 470 nf capacitor. 19 lcdvp1 analog output. a 100 nf capacitor should be connected between this pin and lcdvp2 for the internal lcd charge pump device. 35 to 20 fp0 to f15 lcd segment output 0 to lcd segment output 15. 36 p1.1/txd general-purpose digital i/o port 1.1 or transmitter data output (asynchronous). 37 p1.0/rxd general-purpose digital i/o port 1.0 or receiver data input (asynchronous). 38 p0.7/ ss /t1 general-purpose digital i/o port 0.7, slave select when spi is in slave mode or timer 1 input. 39 p0.6/sclk/t0 general-purpose digital i/o port 0.6, clock output for i 2 c or spi port, or timer 0 input. 40 p0.5/miso general-purpose digital i/o port 0.5 or data input for spi port. 41 p0.4/mosi/sdata general-purpose digital i/o port 0.4, data line i 2 c-compatible, or data output for spi port. 42 p0.3/cf2 general-purpose digital i/o port 0.3 or calibration frequency logic output 2. the cf2 logic output gives instantaneous active, reactive, i rms , or apparent power information.
ADE7566/ade7569/ade7166/ade7169 rev. a | page 17 of 144 pin no. mnemonic description 43 p0.2/cf1/rtccal general-purpose digital i/o port 0.2, calibration frequency logic output 1, or rtc calibration frequency logic output. the cf1 logic output gives instantaneous active, reactive, i rms , or apparent power information. the rtccal logic output gives access to the calibrated rtc output. 44 sden /p2.3 serial download mode enable or digital output pin p2 .3. this pin is used to en able serial download mode through a resistor when pulled low on power-up or reset. on reset, this pin momentarily becomes an input and the status of the pin is sampled. if there is no pu ll-down resistor in place, the pin momentarily goes high and then user code is executed. if the pin is pulled down on reset, the embedd ed serial download/debug kernel executes, and this pin remains low during the in ternal program execution. after reset, this pin can be used as a digital output port pin (p2.3). 45 bctrl/ int1 /p0.0 digital input for battery control, external interrupt in put 1, or general-purpose digital i/o port 0.0. this logic input connects v dd or v bat to v swout internally when set to logic high or logic low, respectively. when left open, the connection between v dd or v bat and v swout is selected internally. 46 xtal2 a crystal can be connected across this pin and xtal1 (see xtal1 pin description) to provide a clock source for the ADE7566/ade7569/ade7166/ade7169. the xtal2 pin can drive one cmos load when an external clock is supplied at xtal1 or by the gate oscillator circui t. an internal 6 pf capacito r is connected to this pin. 47 xtal1 an external clock can be provided at this logic input. alternatively, a parallel resonant at crystal can be connected across xtal1 and xtal2 to provide a cl ock source for the ADE7566/ade7569/ade7166/ade7169. the clock frequency for specified operation is 32.768 khz. an internal 6 pf capacitor is connected to this pin. 48 int0 external interrupt input 0. 49, 50 v p , v n analog inputs for voltage channel. these inputs ar e fully differential voltage inputs with a maximum differential level of 400 mv for specified opera tion. this channel also has an internal pga. 51 ea this pin is used as an input for emulation. when held high, this input enables the device to fetch code from internal program memory locations. the ADE7566/ ade7569/ade7166/ade7169 do not support external code memory. this pin should not be left floating. 52, 53 i p or i pa , i n analog inputs for current channel. these inputs are fully differential voltage inputs with a maximum differential level of 400 mv for specified operati on. this channel also has an internal pga. 54 agnd this pin provides the ground reference for the analog circuitry. 55 fp26 or i pb lcd segment output 26 (fp26) for ADE7566 and ade7569 or analog inputs for second current channel (i pb ) for ade7166 and ade7169. this input is fully differenti al with a maximum differential level of 400 mv referred to i n for specified operation. this channel also has an internal pga. 56 reset reset input, active low. 57 ref in/out this pin provides access to the on-chip voltage reference. the on-chip reference has a nominal value of 1.2 v 0.1% and a typical temperature coefficient of 50 ppm/c maximum. this pin should be decoupled with a 1 f capacitor in parallel with a ceramic 100 nf capacitor. 58 v bat power supply input from the battery with a 2.4 v to 2. 7 v range. this pin is connected internally to v dd when the battery is selected as the power su pply for the ADE7566/ade7569/ade7166/ade7169. 59 v inta this pin provides access to the on-chip 2.5 v analog ldo. no external active circuitry should be connected to this pin. this pin should be decoupled with a 10 f capacitor in parallel with a ceramic 100 nf capacitor. 60 v dd 3.3 v power supply input from the regulator. this pin is connected internally to v dd when the regulator is selected as the power supply for the ADE7566/ade 7569/ade7166/ade7169. this pin should be decoupled with a 10 f capacitor in parallel with a ceramic 100 nf capacitor. 61 v swout 3.3 v power supply output. this pin provides the supply voltage for the ldos and internal circuitry of the ADE7566/ade7569/ade7166/ade7169. this pin should be de coupled with a 10 f capacitor in parallel with a ceramic 100 nf capacitor. 62 v intd this pin provides access to the on-chip 2.5 v digital ldo. no external active circuitry should be connected to this pin. this pin should be decoupled with a 10 f capacitor in parallel with a ceramic 100 nf capacitor. 63 dgnd this pin provides the ground reference for the digital circuitry. 64 v dcin analog input for dc voltage monitoring. th e maximum input voltage on this pin is v swout with respect to agnd. this pin is used to monito r the preregulated dc voltage.
ADE7566/ade7569/ade7166/ade7169 rev. a | page 18 of 144 typical performance characteristics ?2.0 ?1.5 ?1.0 ?0.5 0 0.5 1.0 1.5 2.0 ?40c; pf = 1 +25c; pf = 1 +85c; pf = 1 mid class c mid class c 0.1 1 10 100 0 6353-107 current channel (% of full scale) error (% of reading) gain = 1 integrator off internal reference ?2.0 ?1.5 ?1.0 ?0.5 0 0.5 1.0 1.5 2.0 0.1 1 10 100 0 6353-115 current channel (% of full scale) error (% of reading) gain = 1 integrator off internal reference +85c; pf = 0.866 +25c; pf = 0.866 ?40c; pf = 0.866 +85c; pf = 0 +25c; pf = 0 ?40c; pf = 0 figure 10. active energy error as a percentage of reading (gain = 1) over temperature with internal reference, integrator off figure 13. reactive energy error as a percentage of reading (gain = 1) over power factor with internal reference, integrator off ?2.0 ?1.5 ?1.0 ?0.5 0 0.5 1.0 1.5 2.0 ?40c; pf = 1 +25c; pf = 1 +85c; pf = 1 mid class c mid class c 0.1 1 10 100 0 6353-109 current channel (% of full scale) error (% of reading) gain = 1 integrator off internal reference gain = 1 integrator off internal reference ?1.5 ?1.0 ?0.5 0 0.5 1.0 1.5 0.1 1 10 100 06353-108 current channel (% of full scale) error (% of reading) mid class c mid class c +25c; pf = 1 +85c; pf = 1 ?40c; pf = 1 +25c; pf = 0.5 +85c; pf = 0.5 ?40c; pf = 0.5 figure 14. current rms error as a percentage of reading (gain = 1) over temperature with internal reference, integrator off figure 11. active energy error as a percentage of reading (gain = 1) over power factor with internal reference, integrator off ?2.0 ?1.5 ?1.0 ?0.5 0 0.5 1.0 1.5 2.0 ?40c; pf = 1 ?40c; pf = 0.5 +25c; pf = 1 +25c; pf = 0.5 +85c; pf = 0.5 +85c; pf = 1 mid class c mid class c 0.1 1 10 100 0 6353-110 current channel (% of full scale) error (% of reading) gain = 1 integrator off internal reference ?2.0 ?1.5 ?1.0 ?0.5 0 0.5 1.0 1.5 2.0 0.1 1 10 100 06353-114 current channel (% of full scale) error (% of reading) gain = 1 integrator off internal reference +85c; pf = 0 +25c; pf = 0 ?40c; pf = 0 figure 15. current rms error as a percentage of reading (gain = 1) over power factor with internal reference, integrator off figure 12. reactive energy error as a percentage of reading (gain = 1) over temperature with internal reference, integrator off
ADE7566/ade7569/ade7166/ade7169 rev. a | page 19 of 144 ?1.5 ?1.0 ?0.5 0 0.5 1.0 1.5 0.1 1 10 100 pf = +0.5 pf = 1 pf = ?0.5 mid class c mid class c 06353-094 current channel (% of full scale) error (% of reading) gain = 8 integrator off internal reference ?0.5 ?0.4 ?0.3 ?0.2 ?0.1 0 0.1 0.2 0.3 0.4 0.5 0.1 1 10 100 06353-111 current channel (% of full scale) error (% of reading) gain = 1 integrator off internal reference v rms ; 3.3v i rms ; 3.13v i rms ; 3.3v i rms ; 3.43v v rms ; 3.13v v rms ; 3.43v figure 19. active energy error as a percentage of reading (gain = 8) over power factor with internal reference, integrator off figure 16. voltage and current rms error as a percentage of reading (gain = 1) over power supply with internal reference ?0.8 ?0.6 ?0.4 ?0.2 0 0.2 0.4 0.6 0.8 pf = +0.5 pf = ?0.5 ?1.0 1.0 0.1 1 10 100 06353-095 current channel (% of full scale) error (% of reading) gain = 8 integrator off internal reference pf = 1 ?1.0 ?0.8 ?0.6 ?0.4 ?0.2 0 0.2 0.4 0.6 0.8 1.0 40 45 50 55 60 65 70 pf = 1 pf = 0.5 mid class b mid class b gain = 1 integrator off internal reference 06353-112 line frequency (hz) error (% of reading) figure 20. reactive energy error as a percentage of reading (gain = 8) over power factor with internal reference, integrator off figure 17. active energy error as a percentage of reading (gain = 1) over frequency with internal reference, integrator off ?1.5 ?1.0 ?0.5 0 0.5 1.0 1.5 0.1 1 10 100 pf = +0.5 pf = 1 pf = ?0.5 mid class c mid class c 06353-096 current channel (% of full scale) error (% of reading) gain = 8 integrator off internal reference ?0.5 ?0.4 ?0.3 ?0.2 ?0.1 0 0.1 0.2 0.3 0.4 0.5 0.1 1 10 100 06353-113 current channel (% of full scale) error (% of reading) gain = 1 integrator off internal reference var; 3.3v w; 3.43v w; 3.13v w; 3.3v var; 3.43v var; 3.13v figure 21. current rms error as a percentage of reading (gain = 8) over power factor with internal reference, integrator off figure 18. active and reactive energy error as a percentage of reading (gain = 1) over power supply with internal reference, integrator off
ADE7566/ade7569/ade7166/ade7169 rev. a | page 20 of 144 ?0.8 ?1.0 ?0.6 ?0.4 ?0.2 0 0.2 0.4 0.6 0.8 1.0 0.1 1 10 100 0 6353-100 current channel (% of full scale) error (% of reading) gain = 16 integrator off internal reference ?40c; pf = 0 +85c; pf = 0 +85c; pf = 0.866 ?40c; pf = 0.866 +25c; pf = 0.866 +25c; pf = 0 ?2.0 ?1.5 ?1.0 ?0.5 0 0.5 1.0 1.5 2.0 ?40c; pf = 1 +25c; pf = 1 +85c; pf = 1 mid class c mid class c 0.1 1 10 100 0 6353-097 current channel (% of full scale) error (% of reading) gain = 16 integrator off internal reference figure 22. active energy error as a percentage of reading (gain = 16) over temperature with internal reference, integrator off figure 25. reactive energy error as a percentage of reading (gain = 16) over power factor with internal reference, integrator off ?40c; pf = 1 +85c; pf = 1 mid class c mid class c ?2.0 ?1.5 ?1.0 ?0.5 0 0.5 1.0 1.5 2.0 0.1 1 10 100 06353-101 current channel (% of full scale) error (% of reading) gain = 16 integrator off internal reference +25c; pf = 1 mid class c mid class c ?2.0 ?1.5 ?1.0 ?0.5 0 0.5 1.0 1.5 2.0 0.1 1 10 100 06353-098 current channel (% of full scale) error (% of reading) gain = 16 integrator off internal reference +85c; pf = 1 ?40c; pf = 1 ?40c; pf = 0.5 +85c; pf = 0.5 +25c; pf = 1 +25c; pf = 0.5 figure 23. active energy error as a percentage of reading (gain = 16) over power factor with internal reference, integrator off figure 26. current rms error as a percentage of reading (gain = 16) over temperature with internal reference, integrator off mid class c mid class c ?2.0 ?1.5 ?1.0 ?0.5 0 0.5 1.0 1.5 2.0 0.1 1 10 100 06353-102 current channel (% of full scale) error (% of reading) gain = 16 integrator off internal reference ?40c; pf = 1 +25c; pf = 1 ?40c; pf = 0.5 +85c; pf = 0.5 +25c; pf = 0.5 +85c; pf = 1 ?0.8 ?0.6 ?0.4 ?0.2 0 0.2 0.4 0.6 0.8 ?1.0 1.0 0.1 1 10 100 06353-099 current channel (% of full scale) error (% of reading) gain = 16 integrator off internal reference +85c; pf = 0 ?40c; pf = 0 +25c; pf = 0 figure 27. current rms error as a percentage of reading (gain = 16) over power factor with internal reference, integrator off figure 24. reactive energy error as a percentage of reading (gain = 16) over temperature with internal reference, integrator off
ADE7566/ade7569/ade7166/ade7169 rev. a | page 21 of 144 mid class c mid class c ?2.0 ?1.5 ?1.0 ?0.5 0 0.5 1.0 1.5 2.0 0.1 1 10 100 06353-103 current channel (% of full scale) error (% of reading) gain = 16 integrator on internal reference ?40c; pf = 1 +85c; pf = 0.5 +25c; pf = 0.5 ?40c; pf = 0.5 +25c; pf = 1 +85c; pf = 1 ?40c; pf = 1 mid class c mid class c ?2.0 ?1.5 ?1.0 ?0.5 0 0.5 1.0 1.5 2.0 0.1 1 10 100 06353-105 current channel (% of full scale) error (% of reading) gain = 16 integrator on internal reference +25c; pf = 1 +25c; pf = 0.5 +85c; pf = 0.5 +85c; pf = 1 ?40c; pf = 0.5 figure 28. active energy error as a percentage of reading (gain = 16) over power factor with internal reference, integrator on figure 30. current rms error as a percentage of reading (gain = 16) over power factor with internal reference, integrator on ?0.8 ?0.6 ?0.4 ?0.2 0 0.2 0.4 0.6 0.8 ?1.0 1.0 0.1 1 10 100 0 6353-104 current channel (% of full scale) error (% of reading) gain = 16 integrator on internal reference +25c; pf = 0 +85c; pf = 0.866 ?40c; pf = 0 +25c; pf = 0.866 +85c; pf = 0 ?40c; pf = 0.866 figure 29. reactive energy error as a percentage of reading (gain = 16) over power factor with internal reference, integrator on
ADE7566/ade7569/ade7166/ade7169 rev. a | page 22 of 144 terminology for the dc psr measurement, a reading at nominal supplies (3.3 v) is taken. a second reading is obtained with the same input signal levels when the supplies are varied 5%. any error introduced is again expressed as a percentage of the reading. measurement error the error associated with the energy measurement made by the ADE7566/ade7569/ade7166/ade7169 is defined by the following formula: adc offset error %100 ? ? ? ? ? ? ? ? ? = energytrue energytrue register energy error percentage adc offset error is the dc offset associated with the analog inputs to the adcs. it means that, with the analog inputs connected to agnd, the adcs still see a dc analog input signal. the magnitude of the offset depends on the gain and input range selection (see the phase error between channels the digital integrator and the high-pass filter (hpf) in the current channel have a nonideal phase response. to offset this phase response and equalize the phase response between channels, two phase correction networks are placed in the current channel: one for the digital integrator and the other for the hpf. the phase correction networks correct the phase response of the corresponding component and ensure a phase match between current channel and voltage channel to within 0.1 over a range of 45 hz to 65 hz with the digital integrator off. with the digital integrator on, the phase is corrected to within 0.4 over a range of 45 hz to 65 hz. typical performance characteristics section). however, when hpf1 is switched on, the offset is removed from the current channel, and the power calculation is not affected by this offset. the offsets can be removed by performing an offset calibration (see the analog inputs section). gain error gain error is the difference between the measured adc output code (minus the offset) and the ideal output code (see the current channel adc section and the voltage channel adc section). it is measured for each of the gain settings on the current channel (1, 2, 4, 8, and 16). the difference is expressed as a percentage of the ideal code. power supply rejection (psr) psr quantifies the ADE7566/ade7569/ade7166/ade7169 measurement error as a percentage of reading when the power supplies are varied. for the ac psr measurement, a reading at nominal supplies (3.3 v) is taken. a second reading is obtained with the same input signal levels when an ac (100 mv rms/120 hz) signal is introduced onto the supplies. any error introduced by this ac signal is expressed as a percentage of reading (see the measurement error definition).
ADE7566/ade7569/ade7166/ade7169 rev. a | page 23 of 144 sfr mapping table 14. mnemonic address details intpr 0xff table 16 scratch4 0xfe table 24 scratch3 0xfd table 23 scratch2 0xfc table 22 scratch1 0xfb table 21 batvth 0xfa table 51 strbper 0xf9 table 48 ipsmf 0xf8 table 17 tempcal 0xf7 table 127 rtccomp 0xf6 table 126 batpr 0xf5 table 18 periph 0xf4 table 19 diffprog 0xf3 table 49 b 0xf0 table 55 vdcinadc 0xef table 52 lcdsege2 0xed table 88 ipsme 0xec table 20 spistat 0xea table 142 spi2cstat 0xea table 147 spimod2 0xe9 table 141 i2cadr 0xe9 table 146 spimod1 0xe8 table 140 i2cmod 0xe8 table 145 wav2h 0xe7 table 30 wav2m 0xe6 table 30 wav2l 0xe5 table 30 wav1h 0xe4 table 30 wav1m 0xe3 table 30 wav1l 0xe2 table 30 acc 0xe0 table 55 batadc 0xdf table 53 mirqsth 0xde table 41 mirqstm 0xdd table 40 mirqstl 0xdc table 39 mirqenh 0xdb table 44 mirqenm 0xda table 43 mirqenl 0xd9 table 42 adcgo 0xd8 table 50 tempadc 0xd7 table 54 irmsh 0xd6 table 30 irmsm 0xd5 table 30 irmsl 0xd4 table 30 vrmsh 0xd3 table 30 vrmsm 0xd2 table 30 vrmsl 0xd1 table 30 mnemonic address details psw 0xd0 table 56 th2 0xcd table 110 tl2 0xcc table 111 rcap2h 0xcb table 112 rcap2l 0xca table 113 t2con 0xc8 table 105 eadrh 0xc7 table 100 eadrl 0xc6 table 99 powcon 0xc5 table 25 kyreg 0xc1 table 116 wdcon 0xc0 table 75 protr 0xbf table 98 protb1 0xbe table 97 protb0 0xbd table 96 edata 0xbc table 95 protky 0xbb table 94 flshky 0xba table 93 econ 0xb9 table 92 ip 0xb8 table 69 pinmap2 0xb4 table 152 pinmap1 0xb3 table 151 pinmap0 0xb2 table 150 lcdcony 0xb1 table 81 cfg 0xaf table 62 lcddat 0xae table 87 lcdptr 0xac table 86 ieip2 0xa9 table 70 ie 0xa8 table 68 dpcon 0xa7 table 66 intval 0xa6 table 125 hour 0xa5 table 124 min 0xa4 table 123 sec 0xa3 table 122 hthsec 0xa2 table 121 timecon 0xa1 table 120 p2 0xa0 table 155 epcfg 0x9f table 149 sbaudt 0x9e table 134 sbaudf 0x9d table 135 lcdconx 0x9c table 79 spi2crx 0x9b table 139 spi2ctx 0x9a table 138 sbuf 0x99 table 133 scon 0x98 table 132 lcdsege 0x97 table 85
ADE7566/ade7569/ade7166/ade7169 rev. a | page 24 of 144 mnemonic address details lcdclk 0x96 table 82 lcdcon 0x95 table 78 mdath 0x94 table 30 mdatm 0x93 table 30 mdatl 0x92 table 30 maddpt 0x91 table 30 p1 0x90 table 154 th1 0x8d table 108 th0 0x8c table 106 mnemonic address details tl1 0x8b table 109 tl0 0x8a table 107 tmod 0x89 table 103 tcon 0x88 table 104 pcon 0x87 table 57 dph 0x83 table 59 dpl 0x82 table 58 sp 0x81 table 61 p0 0x80 table 153
ADE7566/ade7569/ade7166/ade7169 rev. a | page 25 of 144 power management the ADE7566/ade7569/ade7166/ade7169 have elaborate power management circuitry that manages the regular power supply to battery switchover and power supply failures. the power management functionalities can be accessed directly through the 8052 sfrs (see tabl e 15 ). table 15. power management sfrs sfr address r/w mnemonic description 0xec r/w ipsme power management interrupt enable. see table 20 . 0xf5 r/w batpr battery switchover configuration. see table 18 . 0xf8 r/w ipsmf power management interrupt flag. see table 17 . 0xff r/w intpr interrupt pins configuration. see table 16 . 0xf4 r/w periph peripheral configuration sfr. see table 19 . 0xc5 r/w powcon power control. see table 25 . 0xfb r/w scratch1 scratch pad 1. see table 21 . 0xfc r/w scratch2 scratch pad 2. see table 22 . 0xfd r/w scratch3 scratch pad 3. see table 23 . 0xfe r/w scratch4 scratch pad 4. see table 24 . power management register details table 16. interrupt pins configuration sfr (intpr, 0xff) bit mnemonic default description 7 rtccal 0 controls rtc calibration output. when set, the rt c calibration frequency selected by fsel[1:0] is output on the p0.2/cf1/rtccal pin. sets rtc calibration output freq uency and calibration window. fsel[1:0] result (calibration window, frequency) 00 30.5 sec, 1 hz 01 30.5 sec, 512 hz 10 0.244 sec, 500 hz 6 to 5 fsel[1:0] 00 11 0.244 sec, 16.384 khz 4 reserved controls the function of int1 . int1prg[2:0] result x00 gpio enabled x01 bctrl enabled 01x int1 input disabled 3 to 1 int1prg[2:0] 000 11x int1 input enabled controls the function of int0 . int0prg result 0 int0 input disabled 0 int0prg 0 1 int0 input enabled writing to the interrupt pins configuration sfr (intpr, 0xff) to protect the rtc from runaway code, a key must be written to the key sfr (kyreg, 0xc1) to obtain write access to intpr. kyreg (see table 116 ) should be set to 0xea to unlock this sfr and reset to zero after a timekeeping register is written to. the rtc registers can be written using the following 8052 assembly code: mov kyreg, #0eah mov intpr, #080h
ADE7566/ade7569/ade7166/ade7169 rev. a | page 26 of 144 table 17. power management interrupt flag sfr (ipsmf, 0xf8) bit address mnemonic default description 7 0xff fpsr 0 power supply restored interrupt flag. set when the v dd power supply has been restored. this occurs when the source of v swout changes from v bat to v dd . 6 0xfe fpsm 0 psm interrupt flag. set when an enabled psm interrupt condition occurs. 5 0xfd fsag 0 voltage sag interrupt flag. set when an ade energy measurement sag condition occurs. 4 0xfc reserved 0 this bit must be kept cleared for proper operation. 3 0xfb fvadc 0 v dcin monitor interrupt flag. set when v dcin changes by vdcin_diff or when v dcin measurement is ready. 2 0xfa fbat 0 v bat monitor interrupt flag. set when v bat falls below batvth or when v bat measurement is ready. 1 0xf9 fbso 0 battery switchover interrupt flag. set when v swout switches from v dd to v bat. 0 0xf8 fvdcin 0 v dcin monitor interrupt flag. set when v dcin falls below 1.2 v. table 18. battery switchover configuration sfr (batpr, 0xf5) bit mnemonic default description 7 to 2 reserved 00 these bits must be kept to 0 for proper operation. control bits for battery switchover. batprg[1:0] result 00 battery switchover enabled on low v dd 01 battery switchover enabled on low v dd and low v dcin 1 to 0 batprg[1:0] 00 1x battery switchover disabled table 19. peripheral configuration sfr (periph, 0xf4) bit mnemonic default description 7 rxflag 0 if set, indicates that an rx edge event triggered wake-up from psm2. 6 vswsource 1 indicates the power supply that is internally connected to v swout (0 v swout = v bat , 1 v swout = v dd ). 5 vdd_ok 1 if set, indicates that v dd power supply is ready for operation. 4 pll_flt 0 if set, indicates that a pll fault occurred where the pll lost lock. set the pllack bit (see table 50 ) in the start adc measurement sfr (adcgo, 0xd8) to acknowledge the fault and clear the pll_flt bit. 3 ref_bat_en 0 set this bit to enable inte rnal voltage reference in psm2 mode. this bit should be set if lcd is on in psm2 mode. 2 reserved 0 this bit should be kept to zero. controls the function of the p1.0/rxd pin. rxprog[1:0] result 00 gpio 01 rxd with wake-up disabled 1 to 0 rxprog[1:0] 00 11 rxd with wake-up enabled table 20. power management interrupt enable sfr (ipsme, 0xec) bit interrupt enable bit default description 7 epsr 0 enables a psm interrupt when the pow er supply restored flag (fpsr) is set. 6 reserved 0 reserved. 5 esag 0 enables a psm interrupt when the voltage sag flag (fsag) is set. 4 reserved 0 this bit must be kept cleared for proper operation. 3 evadc 0 enables a psm interrupt when the v adc monitor flag (fvadc) is set. 2 ebat 0 enables a psm interrupt when the v bat monitor flag (fbat) is set. 1 ebso 0 enables a psm interrupt when the battery switchover flag (fbso) is set. 0 evdcin 0 enables a psm interrupt when the v dcin monitor flag (fvdcin) is set. table 21. scratch pad 1 sfr (scratch1, 0xfb) bit mnemonic default description 7 to 0 scratch1 0 value can be written/read in this register . this value is maintained in all the power saving modes.
ADE7566/ade7569/ade7166/ade7169 rev. a | page 27 of 144 table 22. scratch pad 2 sfr (scratch2, 0xfc) bit mnemonic default description 7 to 0 scratch2 0 value can be written/read in this register. this value is maintained in all the power saving modes. table 23. scratch pad 3 sfr (scratch3, 0xfd) bit mnemonic default description 7 to 0 scratch3 0 value can be written/read in this register. this value is maintained in all the power saving modes. table 24. scratch pad 4 sfr (scratch4, 0xfe) bit mnemonic default description 7 to 0 scratch4 0 value can be written/read in this register. this value is maintained in all the power saving modes. clearing the scratch pad registers (scratch1, 0xfb to scratch4, 0xfe) note that these scratch pad registers are only cleared when the part loses v dd and v bat . they are not cleared by software, watchdog, or pll reset and, therefore, need to be set correctly in these situations. table 25. power control sfr (powcon, 0xc5) bit mnemonic default description 7 reserved 1 reserved. 6 meter_off 0 set this bit to turn off the modulators and energy metering dsp circuitry to reduce power if metering functions are not needed in psm0. 5 reserved 0 this bit should be kept at 0 for proper operation. 4 coreoff 0 set this bit to shut down the core and enter psm2 if in the psm1 operating mode. 3 reserved 0 reserved. controls the core clock frequency, f core . f core = 4.096 mhz/2 cd . cd[2:0] result ( f core in mhz) 000 4.096 001 2.048 010 1.024 011 0.512 100 0.256 101 0.128 110 0.064 2 to 0 cd[2:0] 010 111 0.032 writing to the power control sfr (powcon, 0xc5) writing data to the powcon sfr involves writing 0xa7 into the key sfr (kyreg, 0xc1), which is described in table 116 , followed by a write to the powcon sfr. for example: mov kyreg,#0a7h ;write kyreg to 0xa7 to get write access to the powcon sfr mov powcon,#10h ;shutdown the core
ADE7566/ade7569/ade7166/ade7169 rev. a | page 28 of 144 the battery switchover functionality provided by the ADE7566/ade7569/ade7166/ade7169 allows a seamless transition from v dd to v bat . an automatic battery switchover option ensures a stable power supply to the ADE7566/ ade7569/ade7166/ade7169, as long as the external battery voltage is above 2.75 v. it allows continuous code execution even while the internal power supply is switching from v dd to v bat and back. note that the energy metering adcs are not available when v bat is being used for v swout . power supply architecture each ADE7566/ade7569/ade7166/ade7169 has two power supply inputs, v dd and v bat , and require only a single 3.3 v power supply at v dd for full operation. a battery backup, or secondary power supply, with a maximum of 3.7 v can be connected to the v bat input. internally, the ADE7566/ade7569/ ade7166/ade7169 connect v dd or v bat to v swout , which is used to derive power for the ADE7566/ade7569/ ade7166/ade7169 circuitry. the v swout output pin reflects the voltage at the internal power supply (v swout ) and has a maximum output current of 6 ma. this pin can also be used to power a limited number of peripheral components. the 2.5 v analog supply (v inta ) and the 2.5 v supply for the core logic (v intd ) are derived by on- chip linear regulators from v swout . power supply monitor (psm) interrupts can be enabled to indicate when battery switchover occurs and when the v dd power supply is restored (see the power supply monitor interrupt (psm) section.) figure 31 shows the power supply architecture of ADE7566/ade7569/ade7166/ade7169. v dd to v bat the following three events switch the internal power supply (v swout ) from v dd to v bat : the ADE7566/ade7569/ade7166/ade7169 provide automatic battery switchover between v dd and v bat based on the voltage level detected at v dd or v dcin . additionally, the bctrl input can be used to trigger a battery switchover. the conditions for switching v swout from v dd to v bat and back to v dd are described in the ? v dcin < 1.2 v. when v dcin falls below 1.2 v, v swout switches from v dd to v bat . this event is enabled when the batprg[1:0] bits in the battery switchover configuration sfr (batpr, 0xf5) = 0b01. setting these bits disables switchover based on v dcin . battery switchover on low v dcin is disabled by default. battery switchover section. v dcin is an input pin that can be connected to a 0 v to 3.3 v dc signal. this input is intended for power supply supervisory purposes and does not provide power to the ADE7566/ade7569/ade7166/ ade7169 circuitry (see the ? v dd < 2.75 v. when v dd falls below 2.75 v, v swout switches from v dd to v bat . this event is enabled when batprg[1:0] in the batpr srf are cleared. battery switchover section). power supply management ldo v intd ldo v inta adc v sw adc scratchpad lcd rtc temperature adc 3.3v mcu ade spi/i 2 c uart 2.5v v dcin v dd v bat v swout bctrl 06353-011 ? falling edge on bctrl. when the battery control pin, bctrl, goes low, v swout switches from v dd to v bat . this external switchover signal can trigger a switchover to v bat at any time. setting bits int1prg[4:2] to 0bx01 in the interrupt pins configuration sfr (intpr, 0xff) enables the battery control pin (see tabl e 16 ). switching from v bat to v dd to switch v swout from v bat to v dd , all of the following events that are enabled to force battery switchover must be false: ? v dcin < 1.2 v and v dd < 2.75 v enabled. if the low v dcin condition is enabled, v swout switches to v dd after v dcin remains above 1.2 v and v dd remains above 2.75 v. figure 31. power supply architecture battery switchover the ADE7566/ade7569/ade7166/ade7169 monitor v dd , v bat , and v dcin . automatic battery switchover from v dd to v bat can be configured based on the status of v dd , v dcin , or the bctrl pin. battery switchover is enabled by default. setting bit 1 in the battery switchover configuration sfr (batpr, 0xf5) disables battery switchover so that v dd is always connected to v swout (see ? v dd < 2.75 v enabled. v swout switches back to v dd after v dd remains above 2.75 v. ? bctrl enabled. v swout switches back to v dd after bctrl is high, and the first or second bullet point is satisfied. table 18 ). the source of v swout is indicated by bit 6 in the peripheral configuration sfr (periph, 0xf4), which is described in table 19 . bit 6 is set when v swout is connected to v dd and cleared when v swout is connected to v bat .
ADE7566/ade7569/ade7166/ade7169 rev. a | page 29 of 144 the power management interrupt enable sfr (ipsme, 0xec) controls the events that result in a psm interrupt (see power supply monitor interrupt (psm) table 20 ). the power supply monitor interrupt (psm) alerts the 8052 core of power supply events. the psm interrupt is disabled by default. setting the epsm bit in the interrupt enable and priority 2 sfr (ieip2, 0xa9) enables the psm interrupt (see figure 32 is a diagram illustrating how the psm interrupt vector is shared among the psm interrupt sources. the psm interrupt flags are latched and must be cleared by writing to the ipsmf flag register (see table 70 ). table 17 ). 06353-012 epsr fpsr esag fsag evadc fvadc ebat fbat ebso fbso evdcin fvdcin fpsm epsm true? pending psm interrupt epsr reserved esag reserved evadc ebat ebso evdcin fpsr fpsm fsag reserved fvadc fbat fbso fvdcin reserved pti reserved psi eade eti epsm esi ipsme addr. 0xec ipsmf addr. 0xf8 ieip2 addr. 0xa9 not involved in psm interrupt signal chain figure 32. psm interrupt sources
ADE7566/ade7569/ade7166/ade7169 rev. a | page 30 of 144 battery switchover and power supply restored psm interrupt the ADE7566/ade7569/ade7166/ade7169 can be configured to generate a psm interrupt when the source of v swout changes from v dd to v bat , indicating battery switchover. setting the ebso bit in the power management interrupt enable sfr (ipsme, 0xec) enables this event to generate a psm interrupt (see tabl e 20 ). the ADE7566/ade7569/ade7166/ade7169 can also be configured to generate an interrupt when the source of v swout changes from v bat to v dd , indicating that the v dd power supply has been restored. setting the epsr bit in the power management interrupt enable sfr (ipsme, 0xec) enables this event to generate a psm interrupt. the flags in the ipsme sfr for these interrupts, fbso and fpsr, are set regardless of whether the respective enable bits have been set. the battery switchover and power supply restore event flags, fbso and fpsr, are latched. these events must be cleared by writing a 0 to these bits. bit 6 in the peripheral configuration sfr (periph, 0xf4), vswsource, tracks the source of v swout . the bit is set when v swout is connected to v dd and cleared when v swout is connected to v bat . v dcin adc psm interrupt the ADE7566/ade7569/ade7166/ade7169 can be configured to generate a psm interrupt when v dcin changes magnitude by more than a configurable threshold. this threshold is set in the temperature and supply delta sfr (diffprog, 0xf3), which is described in table 49 . see the external voltage measurement section for more information. setting the evdcin bit in the power management interrupt enable sfr (ipsme, 0xec) enables this event to generate a psm interrupt. the v dcin voltage is measured using a dedicated adc. these measurements take place in the background at intervals to check the change in v dcin . conversions can also be initiated by writing to the start adc measurement sfr (adcgo, 0xd8) described in table 50 . the fvdcin flag indicates when a v dcin measurement is ready. see the external voltage measurement section for details on how v dcin is measured. v bat monitor psm interrupt the v bat voltage is measured using a dedicated adc. these measurements take place in the background at intervals to check the change in v bat . the fbat bit is set when the battery level is lower than the threshold set in the battery detection threshold sfr (batvth, 0xfa), described in table 51 , or when a new measurement is ready in the battery adc value sfr (batadc, 0xdf), described in table 53 . see the battery measurement section for more information. setting the ebat bit in the power management interrupt enable sfr (ipsme, 0xec) enables this event to generate a psm interrupt. v dcin monitor psm interrupt the v dcin voltage is monitored by a comparator. the fvdcin bit in the power management interrupt flag sfr (ipsmf, 0xf8) power management interrupt flag sfr (ipsmf, 0xf8) is set when the v dcin input level is lower than 1.2 v. setting the evdcin bit in the ipsme sfr enables this event to generate a psm interrupt. this event, which is associated with the sag monitoring, can be used to detect a power supply (v dd ) being compromised and to trigger further actions prior to deciding a switch of v dd to v bat . sag monitor psm interrupt the ADE7566/ade7569/ade7166/ade7169 energy measurement dsp monitors the ac voltage input at the v p and v n input pins. the saglvl register is used to set the threshold for a line voltage sag event. the fsag bit in the power management interrupt flag sfr (ipsmf, 0xf8) is set if the line voltage stays below the level set in the saglvl register for the number of line cycles set in the sagcyc register. see the line volt age sag d e te c t ion section for more information. setting the esag bit in the power management interrupt enable sfr (ipsme, 0xec) enables this event to generate a psm interrupt.
ADE7566/ade7569/ade7166/ade7169 rev. a | page 31 of 144 using the power supply features in an energy meter application, the 3.3 v power supply (v dd ) is typically generated from the ac line voltage and regulated to 3.3 v by a voltage regulator ic. the preregulated dc voltage, typically 5 v to 12 v, can be connected to v dcin through a resistor divider. a 3.6 v battery can be connected to v bat . figure 33 shows how the ADE7566/ade7569/ade7166/ ade7169 power supply inputs are set up in this application. figure 34 shows the sequence of events that occurs if the main power supply generated by the psu starts to fail in the power meter application shown in figure 33 . the sag detection can provide the earliest warning of a potential problem on v dd . when a sag event occurs, user code can be configured to backup data and prepare for battery switchover if desired. the relative spacing of these interrupts depends on the design of the power supply. figure 35 shows the sequence of events that occurs if the main power supply starts to fail in the power meter application shown in figure 33 , with battery switchover on low v dcin or low v dd enabled. finally, the transition between v dd and v bat and the different power supply modes (see the operating modes section) are represented in figure 36 and figure 37 . voltage supervisory power supply management ipsmf sfr (addr. 0xf8) v sw v bat v swout v dd 58 61 60 voltage supervisory 64 v dcin 3.3v regulator 5v to 12v dc psu 50 sag detection 49 45 bctrl v p v n (240v, 220v, 110v typical) ac input 06353-013 figure 33. power supply management for energy meter application t 1 t 2 v dd v dcin v p ? v n 2.75v 1.2v sag level trip point sagcyc = 1 sag event (fsag = 1) v dcin event (fvdcin = 1) if switchover on low v dd is enabled, automatic battery switchover v swout connected to v bat bso event (fbso = 1) 0 6353-014 figure 34. power supply management interru pts and battery switchover with only v dd enabled for battery switchover
ADE7566/ade7569/ade7166/ade7169 rev. a | page 32 of 144 table 26. power supply event timing operating modes parameter time description t 1 10 ns min time between when v dcin goes below 1.2 v and when vswf is raised. t 2 10 ns min time between when v dd falls below 2.75 v and when battery switchover occurs. t 3 30 ms time between when v dcin falls below 1.2 v and when battery switchover occurs if v dcin is enabled to cause battery switchover. t 4 130 ms time between when power supply restore conditions are met (v dcin above 1.2 v and v dd above 2.75 v if batpr[1:0] = 0b01 or v dd above 2.75 v if batpr[1:0] = 0b00) and when v swout switches to v dd . 06353-015 t 1 t 3 v dd v dcin v p ? v n 2.75v 1.2v sag level trip point sagcyc = 1 sag event (fsag = 1) v dcin event (fvdcin = 1) if switchover on low v dcin is enabled, automatic battery switchover v swout connected to v bat bso event (fbso = 1) figure 35. power supply management inte rrupts and battery switchover with v dd or v dcin enabled for battery switchover v p ? v n sag level trip point sag event v dcin 1.2v 30ms min. 130ms min. v dcin event v dcin event v bat v dd 2.75v v sw battery switch enabled on low v dcin v sw battery switch enabled on low v dd psm0 psm0 psm0 psm0 psm1 or psm2 06353-016 psm1 or psm2 figure 36. power supply manageme nt transitions between modes
ADE7566/ade7569/ade7166/ade7169 rev. a | page 33 of 144 operating modes psm0 (normal mode) in psm0, normal operating mode, v swout is connected to v dd . all of the analog circuitry and digital circuitry powered by v intd and v inta are enabled by default. in normal mode, the default clock frequency, f core , established during a power-on reset or software reset, is 1.024 mhz. psm1 (battery mode) in psm1, battery mode, v swout is connected to v bat . in this operating mode, the 8052 core and all of the digital circuitry are enabled by default. the analog circuitry for the ade energy metering dsp powered by v inta is disabled. this analog circuitry automatically restarts, and the switch to the v dd power supply occurs when the v dd supply is above 2.75 v and when the pwrdn bit in the mode1 register (0x0b) is cleared (see table 32). the default f core for psm1, established during a power-on reset or software reset, is 1.024 mhz. psm2 (sleep mode) psm2 is a low power consumption sleep mode for use in battery operation. in this mode, v swout is connected to v bat . all of the 2.5 v digital and analog circuitry powered through v inta and v intd are disabled, including the mcu core, resulting in the following: ? the ram in the mcu is no longer valid. ? the program counter for the 8052, also held in volatile memory, becomes invalid when the 2.5 v supply is shut down. therefore, the program does not resume from where it left off but always starts from the power-on reset vector when the ADE7566/ade7569/ade7166/ade7169 exit psm2. the 3.3 v peripherals (temperature adc, vdcin adc, rtc, and lcd) are active in psm2. they can be enabled or disabled to reduce power consumption and are configured for psm2 operation when the mcu core is active (see table 28 for more information about the individual peripherals and their psm2 configuration). the ADE7566/ade7569/ade7166/ade7169 remain in psm2 until an event occurs to wake them up. in psm2, the ADE7566/ade7569/ade7166/ade7169 provide four scratch pad ram sfrs that are maintained during this mode. these sfrs can be used to save data from psm0 or psm1 when entering psm2 (see table 21 to table 24). in psm2, the ADE7566/ade7569/ade7166/ade7169 maintain some sfrs (see table 27). the sfrs that are not listed in this table should be restored when the part enters psm0 or psm1 from psm2. table 27. sfr maintained in psm2 i/o configuration power supply monitoring rtc peripherals lcd peripherals interrupt pins configuration sfr (intpr, 0xff), see table 16 battery detection threshold sfr (batvth, 0xfa), see table 51 rtc nominal compensation sfr (rtccomp, 0xf6), see table 126 lcd segment enable 2 sfr (lcdsege2, 0xed), see table 88 peripheral configuration sfr (periph, 0xf4), see table 19 battery switchover configura-tion sfr (batpr, 0xf5), see table 18 rtc temperature compensation sfr (tempcal, 0xf7), see table 127 lcd configuration y sfr (lcdcony, 0xb1),see table 81 port 0 weak pull-up enable sfr (pinmap0, 0xb2), see table 150 battery adc value sfr (batadc, 0xdf), see table 53 rtc configuration sfr (timecon, 0xa1), see table 120 lcd configuration x sfr (lcdconx, 0x9c), see table 79 port 1 weak pull-up enable sfr (pinmap1, 0xb3), see table 151 peripheral adc strobe period sfr (strbper, 0xf9), see table 48 hundredths of a second counter sfr (hthsec, 0xa2), see table 121 lcd configuration sfr (lcdcon, 0x95), see table 78 port 2 weak pull-up enable sfr (pinmap2, 0xb4), see table 152 temperature and supply delta sfr (diffprog, 0xf3), see table 49 seconds counter sfr (sec, 0xa3), see table 122 lcd clock sfr (lcdclk, 0x96), see table 82 scratch pad 1 sfr (scratch1, 0xfb), see table 21 vdcin adc value sfr (vdcinadc, 0xef), see table 52 minutes counter sfr (min, 0xa4), see table 123 lcd segment enable sfr (lcdsege, 0x97) see table 85 scratch pad 2 sfr (scratch2, 0xfc), see table 22 temperature adc value sfr (tempadc, 0xd7), see table 54 hours counter sfr (hour, 0xa5), see table 124 lcd pointer sfr (lcdptr, 0xac), see table 86 scratch pad 3 sfr (scratch3, 0xfd), see table 23 alarm interval sfr (intval, 0xa6), see table 125 lcd data sfr (lcddat, 0xae), see table 87 scratch pad 4 sfr (scratch4, 0xfe), see table 24
ADE7566/ade7569/ade7166/ade7169 rev. a | page 34 of 144 3.3 v peripherals and wake-up events some of the 3.3 v peripherals are capable of waking the ADE7566/ade7569/ade7166/ade7169 from psm2. the events that can cause the ADE7566/ade7569/ade7166/ ade7169 to wake up from psm2 are listed in the wake-up events column in table 28 . the interrupt flag associated with these events must be cleared prior to executing instructions that put the ADE7566/ade7569/ ade7166/ade7169 in psm2 mode after wake-up. table 28. 3.3 v peripherals and wake-up events 3.3 v peripheral wake- up event wake-up enable bits flag interrupt vector comments temperature adc ?t maskable itadc the temperature adc can wake up the ADE7566/ade7569/ ade7166/ade7169 if the itadc flag is set. a pending interrupt is generated according to the description in the temperature measurement section. this wake-up event can be disabled by disabling temperature measurements in the temperature and supply delta sfr (diffprog, 0xf3) in psm2. the temperature interrupt needs to be serviced and acknowledged prior to entering psm2 mode. v dcin adc v maskable fvdcin ipsm the v dcin measurement can wake up the ADE7566/ade7569/ ade7166/ade7169. the fvdcin is set according to the description in the external voltage measurement section. this wake-up event can be disabled by clearing the evdcin in the power management interrupt enable sfr (ipsme, 0xec); see table 20 . the fvdcin flag needs to be cleared prior to entering psm2 mode. power supply management psr nonmaskable psr ipsm the ADE7566/ade7569/ade7166/ade7169 wake up if the power supply is restored (if v swout switches to be connected to v dd ). the vswsource flag, bit 6 of the peripheral configuration sfr (periph, 0xf4), is set to indicate that v swout is connected to v dd . midnight nonmaskable midnight irtc the ADE7566/ade7569/ade7166/ade7169 wake up at midnight every day to update their calendars. the rtc interrupt needs to be serviced and acknowledged prior to entering psm2 mode. rtc alarm maskable alarm irtc an alarm can be set to wake the ADE7566/ade7569/ade7166/ ade7169 after the desired amount of time. the rtc alarm is enabled by setting the alarm bit in the rtc configuration sfr (timecon, 0xa1). the rtc interrupt needs to be serviced and acknowledged prior to entering psm2 mode. all i/o pins are treated as inputs. the weak pull-up on each i/ o pin can be disabled individually in the port 0 weak pull-up enable sfr (pinmap0, 0xb2), port 1 weak pull-up enable sfr (pinmap1, 0xb3), and port 2 weak pull-up enable sfr (pinmap2, 0xb4) to decrease current consumptio n. the interrupts can be enabled/disabled. int0 int0prg = 1 ie0 the edge of the interrupt is selected by bit it0 in the tcon register. the ie0 flag bit in the tcon register is not affected. the interrupt 0 interrupt needs to be serviced an d acknowledged prior to entering psm2 mode. int1 int1prg[2:0] = 11x ie1 the edge of the interrupt is selected by bit it1 in the tcon register. the ie1 flag bit in the tcon register is not affected. the interrupt 1 interrupt needs to be serviced and acknowledged prior to entering psm2 mode. i/o ports rx edge rxprog[1:0] = 11 periph.7 (rxfg) an rx edge event occurs if a rising or falling edge is detected on the rx line. the uart rxd flag needs to be cleared prior to entering psm2 mode. external reset reset nonmaskable if the reset pin is brought low while the ADE7566/ade7569/ ade7166/ade7169 is in psm2, it wakes up to psm1. lcd the lcd can be enabled/disabled in psm2. the lcd data memory remains intact. scratch pad the four scratchx registers remain intact in psm2.
ADE7566/ade7569/ade7166/ade7169 rev. a | page 35 of 144 transitioning between operating modes the operating mode of the ADE7566/ade7569/ade7166/ ade7169 is determined by the power supply connected to v swout . therefore, changes in the power supply, such as when v swout switches from v dd to v bat or when v swout switches to v dd , alter the operating mode. this section describes events that change the operating mode. automatic battery switchover (psm0 to psm1) if any of the enabled battery switchover events occur (see the battery switchover section), v swout switches to v bat . this switchover results in a transition from the psm0 to psm1 operating mode. when battery switchover occurs, the analog circuitry used in the ade energy measurement dsp is disabled. to reduce power consumption, the user code can initiate a transition to psm2. entering sleep mode (psm1 to psm2) to reduce power consumption when v swout is connected to v bat , user code can initiate sleep mode, psm2, by setting bit 4 in the power control sfr (powcon, 0xc5) to shut down the mcu core. events capable of waking the mcu can be enabled (see the 3.3 v peripherals and wake-up events section). servicing wake-up events (psm2 to psm1) the ADE7566/ade7569/ade7166/ade7169 may need to wake up from psm2 to service wake-up events (see the 3.3 v peripherals and wake-up events section). psm1 code execution begins at the power-on reset vector. after servicing the wake-up event, the ADE7566/ade7569/ade7166/ ade7169 can return to psm2 by setting bit 4 in the power control sfr (powcon, 0xc5) to shut down the mcu core. automatic switch to v dd (psm2 to psm0) if the conditions to switch v swout from v bat to v dd occur (see the battery switchover section), the operating mode switches to psm0. when this switch occurs, the mcu core and the analog circuitry used in the ade energy measurement dsp automatically restart. psm0 code execution begins at the power- on reset vector. automatic switch to v dd (psm1 to psm0) if the conditions to switch v swout from v bat to v dd occur (see the battery switchover section), the operating mode switches to psm0. when this switch occurs, the analog circuitry used in the ade energy measurement dsp automatically restarts. note that code execution continues normally. a software reset can be performed to start psm0 code execution at the power-on reset vector. using the power management features because program flow is different for each operating mode, the status of v swout must be known at all times. the vswsource bit in the peripheral configuration sfr (periph, 0xf4) indicates what v swout is connected to (see table 19 ). this bit can be used to control program flow on wake-up. because code execution always starts at the power-on reset vector, bit 6 of the periph srf can be tested to determine which power supply is being used and to branch to normal code execution or to wake up event code execution. power supply events can also occur when the mcu core is active. to be aware of the events that change what v swout is connected to, use the following guidelines: ? enable the battery switchover interrupt (ebso) if v swout = v dd at power-up. ? enable the power supply restored interrupt (epsr) if v swout = v bat at power-up. an early warning that battery switchover is about to occur is provided by sag detection and possibly low v dcin detection (see the battery switchover section). for a user-controlled battery switchover, enable automatic battery switchover on low v dd only. then, enable the low v dcin event to generate the psm interrupt. when a low v dcin event occurs, start data backup. upon completion of the data backup, enable battery switchover on low v dcin . battery switchover occurs 30 ms later.
ADE7566/ade7569/ade7166/ade7169 rev. a | page 36 of 144 psm1 battery mode v swout connected to v bat psm0 normal mode v swout connected to v dd psm2 sleep mode v swout connected to v bat power supply restored automatic battery switchover wake-up event user code directs mcu to shutdown core after servicing wake-up event power supply restored 06353-017 figure 37. transitioning between operating modes
ADE7566/ade7569/ade7166/ade7169 rev. a | page 37 of 144 energy measurement the ADE7566/ade7569/ade7166/ade7169 offer a fixed function, energy measurement, digital processing core that provides all the information needed to measure energy in single-phase energy meters. the part provides two ways to access the energy measurements: direct access through sfrs for time sensitive information and indirect access through address and data sfr registers for the majority of energy measurements. the i rms , v rms , interrupts, and waveform registers are readily available through sfrs as shown in table 30 . other energy measurement information is mapped to a page of memory that is accessed indirectly through the maddpt, mdatl, mdatm, and mdath sfrs. the address and data registers act as pointers to the energy measurement internal registers. access to energy measurement sfrs access to the e nergy m easurement sfrs is achieved by reading or writing to the sfr addresses detailed in tabl e 30 . the internal data for the mirqx sfrs are latched byte by byte into the sfr when the sfr is read. the wav1x, wav2x, vrmsx, and irmsx registers are all 3-byte sfrs. the 24-bit data is latched into these sfrs when the high byte is read. reading the low or medium byte before the high byte results in reading the data from the previous latched sample. sample code to read the v rms register is as follows: mov r1, vrmsh //latches data in vrmsh, vrmsm and vrmsl sfr mov r2, vrmsm mov r3, vrmsl access to internal energy measurement registers access to the internal energy measurement registers is achieved by writing to the energy measurement pointer address sfr (maddpt, 0x91). this sfr selects the energy measurement register to be accessed and determines if a read or a write is performed (see table 29 ). table 29. energy measurement pointer address sfr (maddpt, 0x91) bit description 7 1 = write, 0 = read 6 to 0 energy measurement internal register address writing to the internal energy measurement registers when bit 7 of the the energy measurement pointer address sfr (maddpt, 0x91) is set, the content of the mdatx sfrs (mdatl, mdatm, and mdath) is transferred to the internal energy measurement register designated by the address in the maddpt sfr. if the internal register is 1 byte long, only the mdatl sfr content is copied to the internal register, while the mdatm sfr and mdath sfr contents are ignored. the energy measurement core functions with an internal clock of 4.096 mhz M 5 or 819.2 khz. because the 8052 core functions with another clock, 4.096mhz M 2 cd , synchronization between the two clock environments when cd = 0 or 1 is an issue. when data is written to the internal energy measurement registers, a small wait period needs to be implemented before another read or write to these registers can take place. sample code to write 0x0155 to the 2-byte saglvl register located at 0x14 in the energy measurement memory space is shown below. mov mdatm,#01h mov mdatl,#55h mov maddpt,#saglvl_w (address 0x94) mov a,#05h djnz acc,$ ;next write or read to energy measurement sfr can be done after this. reading the internal energy measurement registers when bit 7 of energy measurement pointer address sfr (maddpt, 0x91) is cleared, the content of the internal energy measurement register designated by the address in maddpt is transferred to the mdatx sfrs. if the internal register is 1 byte long, only the mdatl sfr content is updated with a new value, while the mdatm sfr and mdath sfr contents are reset to 0x00. the energy measurement core functions with an internal clock of 4.096 mhz M 5 or 819.2 khz. because the 8052 core functions with another clock, 4.096mhz M 2 cd , synchronization between the two clock environments when cd = 0 or 1 is an issue. when data is read from the internal energy measurement registers, a small wait period needs to be implemented before the mdatx sfrs are transferred to another sfr. sample code to read the peak voltage in the 2-byte vpklvl register located at 0x16 into the data pointer is shown below. mov maddpt,#vpklvl_r (address 0x16) mov a,#05h djnz acc,$ mov dph,mdatm mov dpl,mdatl
ADE7566/ade7569/ade7166/ade7169 rev. a | page 38 of 144 table 30. energy measurement sfrs address r/w name description 0x91 r/w maddpt energy measurement pointer address. 0x92 r/w mdatl energy measurement pointer data lowest significant byte. 0x93 r/w mdatm energy measurement pointer data middle byte. 0x94 r/w mdath energy measurement pointer data most significant byte. 0xd1 r vrmsl v rms measurement lowest significant byte. 0xd2 r vrmsm v rms measurement middle byte. 0xd3 r vrmsh v rms measurement most significant byte. 0xd4 r irmsl i rms measurement lowest significant byte. 0xd5 r irmsm i rms measurement middle byte. 0xd6 r irmsh i rms measurement most significant byte. 0xd9 r/w mirqenl energy measurement inte rrupt enable lowest significant byte. 0xda r/w mirqenm energy measurem ent interrupt enable middle byte. 0xdb r/w mirqenh energy measurement interrupt enable most significant byte. 0xdc r/w mirqstl energy measurement inte rrupt status lowest significant byte. 0xdd r/w mirqstm energy measuremen t interrupt status middle byte. 0xde r/w mirqsth energy measurement in terrupt status most significant byte. 0xe2 r wav1l selection 1 sample lowest significant byte. 0xe3 r wav1m selection 1 sample middle byte. 0xe4 r wav1h selection 1 sample most significant byte. 0xe5 r wav2l selection 2 sample lowest significant byte. 0xe6 r wav2m selection 2 sample middle byte. 0xe7 r wav2h selection 2 sample most significant byte. adc dfc 2 multiplier integrator wattos[15:0] vagain[11:0] vadiv[7:0] irmsos[11:0] vrmsos[11:0] wgain[11:0] dt metering sfrs phcal[7:0] v n v p pga2 cf1 wdiv[7:0] % % 2 2 1, 2, 4, 8, 16 adc i ap i n pga1 i {gain[2:0]} vardiv[7:0] % varos[15:0] vargain[11:0] dfc cf2num[15:0] cf2den[15:0] cf1den[15:0] cf1num[15:0] cf2 hpf hpf lpf lpf lpf2 lpf2 06353-092 figure 38. ADE7566 and ade7569 energy metering block diagram
ADE7566/ade7569/ade7166/ade7169 rev. a | page 39 of 144 adc dfc 2 multiplier integrator wattos[15:0] vagain[11:0] vadiv[7:0] irmsos[11:0] vrmsos[11:0] wgain[11:0] dt metering sfrs phcal[7:0] v 2n v 2p pga2 cf1 wdiv[7:0] % % 2 2 1, 2, 4, 8, 16 adc i ap i n pga1 i {gain[2:0]} vardiv[7:0] % varos[15:0] vargain[11:0] dfc cf2num[15:0] cf2den[15:0] cf1den[15:0] cf1num[15:0] cf2 hpf hpf adc i bp pga1 hpf lpf lpf lpf2 lpf2 06353-117 ibgain[11:0] figure 39. ade7166 and ade7169 energy metering block diagram
ADE7566/ade7569/ade7166/ade7169 rev. a | page 40 of 144 energy measurement registers table 31. energy measurement register list address maddpt[6:0] mnemonic r/w length (bits) signed/ unsigned default description 0x00 reserved 0x01 watthr r 24 s 0 reads wh accumulator without reset. 0x02 rwatthr r 24 s 0 reads wh accumulator with reset. 0x03 lwatthr r 24 s 0 reads wh accumulator synchronous to line cycle. 0x04 varhr 1 r 24 s 0 reads varh accumulator without reset. 0x05 rvarhr 1 r 24 s 0 reads varh accumulator with reset. 0x06 lvarhr 1 r 24 s 0 reads varh accumulator synchronous to line cycle. 0x07 vahr r 24 s 0 reads vah accumulator without reset. if the varmscfcon bit in mode2 register (0x0c) is set, this register accumulates i rms . 0x08 rvahr r 24 s 0 reads vah accumulator with reset. if the varmscfcon bit in mode2 register (0x0c) is set, this register accumulates i rms . 0x09 lvahr r 24 s 0 reads vah accumulator synchronous to line cycle. if the varmscfcon bit in mode2 register (0x0c) is set, this register accumulates i rms . 0x0a per_freq r 16 u 0 reads line period or frequency register depending on mode2 register. 0x0b mode1 r/w 8 u 0x06 sets basic configuration of energy measurement (see table 32 ). 0x0c mode2 r/w 8 u 0x40 sets basic configuration of energy measurement (see table 33 ). 0x0d wavmode r/w 8 u 0 sets configuration of waveform sample 1 and waveform sample 2 (see table 34 ). 0x0e nlmode r/w 8 u 0 sets level of energy no-load thresholds (see table 35 ). 0x0f accmode r/w 8 u 0 sets configuration of w, var accumulation, and various tamper alarms (see table 36 ). 0x10 phcal r/w 8 s 0x40 sets phase calibration register (see the phase compensation section). 0x11 zxtout r/w 12 0x0fff sets timeout for zero-crossin g timeout detection (see the zero- crossing timeout section). 0x12 lincyc r/w 16 u 0xffff sets number of half-line cycles for lwatthr, lvarhr, and lvahr accumulators. 0x13 sagcyc r/w 8 u 0xff sets number of half-line cycles for sag detection (see the line voltage sag detection section). 0x14 saglvl r/w 16 u 0 sets detection level for sag detection (see the line voltage sag detection section). 0x15 ipklvl r/w 16 u 0xffff sets peak detection level for current peak detection (see the peak detection section). 0x16 vpklvl r/w 16 u 0xffff sets peak detection level for voltage peak detection (see the peak detection section). 0x17 ipeak r 24 u 0 reads current peak level without reset (see the peak detection section). 0x18 rstipeak r 24 u 0 reads current peak level with reset (see the peak detection section). 0x19 vpeak r 24 u 0 reads voltage peak level without reset (see the peak detection section). 0x1a rstvpeak r 24 u 0 reads voltag e peak level with reset (see the peak detection section). 0x1b gain r/w 8 u 0 sets pga gain of analog inputs (see table 37 ). 0x1c ibgain 2 r/w 12 s 0 sets matching gain for i pb current input. 0x1d wgain r/w 12 s 0 sets watt gain register. 0x1e vargain 1 r/w 12 s 0 sets var gain register. 0x1f vagain r/w 12 s 0 sets va gain register. 0x20 wattos r/w 16 s 0 sets watt offset register. 0x21 varos 1 r/w 16 s 0 sets var offset register. 0x22 irmsos r/w 12 s 0 sets current rms offset register. 0x23 vrmsos r/w 12 s 0 sets voltage rms offset register. 0x24 wdiv r/w 8 u 0 sets watt energy scaling register. 0x25 vardiv r/w 8 u 0 sets va r energy scaling register.
ADE7566/ade7569/ade7166/ade7169 rev. a | page 41 of 144 address maddpt[6:0] mnemonic r/w length (bits) signed/ unsigned default description 0x26 vadiv r/w 8 u 0 sets va energy scaling register. 0x27 cf1num r/w 16 u 0 sets cf1 numerator register. 0x28 cf1den r/w 16 u 0x003f sets cf1 denominator register. 0x29 cf2num r/w 16 u 0 sets cf2 numerator register. 0x2a cf2den r/w 16 u 0x003f sets cf2 denominator register. 0x3b reserved 0 this register must be kept at its default value for proper operation. 0x3c reserved 0x0300 this register must be kept at its default value for proper operation. 0x3d calmode 2 r/w 8 u 0 for ade7166/ade7169 only. set calibration mode. 0x3e reserved 0 this register must be kept at its default value for proper operation. 0x3f reserved 0 this register must be kept at its default value for proper operation. 1 this function is not availab le in the ADE7566 and ade7166. 2 this function is not availab le in the ADE7566 and ade7569. energy measurement internal registers details table 32. mode1 register (0x0b) bit mnemonic default description 7 swrst 0 setting this bit resets all of the energy measurement registers to their default values. 6 diszxlpf 0 setting this bit disables the zero-crossing low-pass filter. 5 inte 0 setting this bit enables the digita l integrator for use with a di/dt sensor. 4 swapbits 0 setting this bit swaps ch1 adc and ch2 adc. 3 pwrdn 0 setting this bit powers down voltage and current adcs. 2 discf2 1 setting this bit di sables frequency output cf2. 1 discf1 1 setting this bit di sables frequency output cf1. 0 dishpf 0 setting this bi t disables the hpfs in voltage and current channels. table 33. mode2 register (0x0c) bit mnemonic default description configuration bits for cf2 output. cf2sel[1:0] result 00 cf2 frequency is proportional to active power. 01 cf2 frequency is proportional to reactive power. 1 7 to 6 cf2sel[1:0] 01 1x cf2 frequency is proportional to apparent power or i rms . 5 to 4 cf1sel[1:0] 00 configuration bits for cf1 output. cf1sel[1:0] result 00 cf1 frequency is proportional to active power. 01 cf1 frequency is proportional to reactive power. 1 1x cf1 frequency is proportional to apparent power or i rms . 3 varmscfcon 0 configuration bits for apparent power or i rms for cf1, cf2 outputs, and va accumulation registers (vahr, rvahr, and lvahr). note that cf1 cannot be proportional to va if cf2 is proportional to i rms and vice versa. varmscfcon result 0 if cf1sel[1:0] = 1x, cf1 is proportional to va. if cf2sel[1:0] = 1x, cf2 is proportional to va. 1 if cf1sel[1:0] = 1x, cf1 is proportional to i rms . if cf2sel[1:0] = 1x, cf2 is proportional to i rms . 2 zxrms 0 logic 1 enables update of rm s values synchronou sly to voltage zx.
ADE7566/ade7569/ade7166/ade7169 rev. a | page 42 of 144 bit mnemonic default description 1 freqsel configuration bits to select period or frequency measurement for per_freq register (0x0a). freqsel result 0 per_freq register holds a period measurement. 1 per_freq register holds a frequency measurement. 0 waven 0 when set, the waveform sampling mode is enabled. 1 this function is not availab le in the ADE7566 and ade7166. table 34. wavmode register (0x0d) bit mnemonic default description 7 to 5 wav2sel[2:0] 000 waveform 2 selection for samples mode. wav2sel[2:0] source 000 current 001 voltage 010 active power multiplier output 011 reactive power multiplier output 1 100 va multiplier output 101 i rms lpf output others reserved 4 to 2 wav1sel[2:0] 000 waveform 1 selection for samples mode. wav1sel[2:0] source 000 current 001 voltage 010 active power multiplier output 011 reactive power multiplier output 1 100 va multiplier output 101 i rms lpf output (low 24-bit) others reserved 1 to 0 dtrt[1:0] 00 waveform samples output data rate. dtrt[1:0] update rate (clock = f core /5 = 819.2 khz) 00 25.6 ksps (clock/32) 01 12.8 ksps (clock/64) 10 6.4 ksps (clock/128) 11 3.2 ksps (clock/256) 1 this function is not availab le in the ADE7566 and ade7166. table 35. nlmode register (0x0e) bit mnemonic default description 7 disvarcmp 1 0 setting this bit disables fundamental var gain compensation over line frequency. 6 irmsnoload 0 logic 1 enables i rms no-load threshold detection. the level is defined by the setting of the vanoload bits. 5 to 4 vanoload[1:0] 00 apparent power no-load threshold. vanoload[1:0] result 00 no-load detection disabled 01 no-load detection enabled with threshold = 0.030% of full scale 10 no-load detection enabled with threshold = 0.015% of full scale 11 no-load detection enabled with threshold = 0.0075% of full scale
ADE7566/ade7569/ade7166/ade7169 rev. a | page 43 of 144 bit mnemonic default description 3 to 2 varnoload[1:0] 1 00 reactive power no-load threshold. varnoload[1:0] result 00 no-load detection disabled 01 no-load detection enabled with threshold = 0.015% of full scale 10 no-load detection enabled with threshold = 0.0075% of full scale 11 no-load detection enabled with threshold = 0.0037% of full scale 1 to 0 apnoload[1:0] 00 active power no-load threshold. apnoload[1:0] result 00 no-load detection disabled 01 no-load detection enabled with threshold = 0.015% of full scale 10 no-load detection enabled with threshold = 0.0075% of full scale 11 no-load detection enabled with threshold = 0.0037% of full scale 1 this function is not availab le in the ADE7566 and ade7166. table 36. accmode register (0x0f) bit mnemonic default description 7 ichannel 1 0 this bit indicates the current channel used to measure energy in antitampering mode. 0 C channel a 1 C channel b 6 faultsign 1 0 configuration bit to select the even t that triggers a fault interrupt. 0 C fault interrupt occurs when part enters fault mode 1 C fault interrupt occurs when part enters normal mode 5 varsign 2 0 configuration bit to select the event that triggers a reactive power sign interrupt. if set to 0, varsign interrupt occurs when reactive power changes from positive to negative. if set to 1, varsign interrupt occurs when reactive power changes from negative to positive. 4 apsign 0 configuration bit to select event that triggers an active power sign interrupt. if set to 0, apsign interrupt occurs when active power changes from positive to negative. if set to 1, apsign interrupt occurs when active power changes from negative to positive. 3 absvarm 2 0 logic 1 enables absolute value ac cumulation of reactive power in energy register and pulse output. 2 savarm 2 0 logic 1 enables reactive power accumulation depending on the sign of the active power. if active power is positive, var is accumulated as it is. if active power is negative, the sign of the var is reversed for the accumulation. this accumulati on mode affects both the var registers (varhr, rvarhr, lvarhr) and the pulse output when connected to var. 2 1 poam 0 logic 1 enables positive-only accumulation of active power in energy register and pulse output. 0 absam 0 logic 1 enables absolute value accumulation of active power in energy register and pulse output. 1 this function is not availab le in the ADE7566 and ade7569. 2 this function is not availab le in the ADE7566 and ade7166. table 37. gain register (0x1b) bit mnemonic default description 7 to 5 pga2[2:0] 000 these bits defi ne the voltage channel input gain. pga2[2:0] result 000 gain = 1 001 gain = 2 010 gain = 4 011 gain = 8 100 gain = 16 4 reserved 0 reserved. 3 cfsign_opt 0 this bit defines where the cf change of sign detection (apsign or varsign) is implemented. cfsign_opt result 0 filtered power signal 1 on a per cf pulse basis
ADE7566/ade7569/ade7166/ade7169 rev. a | page 44 of 144 bit mnemonic default description 2 to 0 pga1[2:0] 000 these bits defi ne the current channel input gain. pga1[2:0] result 000 gain = 1 1 001 gain = 2 010 gain = 4 011 gain = 8 100 gain = 16 1 this gain is not recommended in the ade7166 and ade7169 because it can create an overranging of the adc when both current inpu ts are in opposite phase. table 38. calmode register (0x3d) 1 bit mnemonic default description 7 to 6 reserved 0 these bits should be kept cleared for proper operation. 5 to 4 sel_i_ch[1:0] 0 these bits define the current channel used for energy measurements. [1:0] 00 current channel automatically sele cted by the tampering condition 01 current channel connected to i pa 10 current channel connected to i pb 11 current channel automatically selected by the tampering condition 3 v_ch_short 0 logic one short voltage channel to ground. 2 i_ch_short 0 logic one short current channels to ground. 1 to 0 reserved 1 this register is not availab le in the ADE7566 and ade7569. interrupt status/enable sfrs table 39. interrupt status 1 sfr (mirqstl, 0xdc) bit interrupt flag description 7 adeirqflag this bit is set if any of the ade status flags that are en abled to generate an ade interrupt are set. this bit is automatically cleared when all of the enabled ade status flags are cleared. 6 reserved reserved. 5 faultsign 1 logic 1 indicates that the fault mode has changed a ccording to the configuration of the accmode register. 4 varsign 2 logic 1 indicates that the reactive power sign has changed according to the configuration of the accmode register. 3 apsign logic 1 indicates that the active power sign has changed according to the configuration of the accmode register. 2 vanoload logic 1 indicates that an interrupt has been caused by apparent power no-load detected. this interrupt is also used to reflect the part entering the i rms no-load mode. 1 rnoload 2 logic 1 indicates that an interrupt has been caused by reactive power no-load detected. 0 apnoload logic 1 indicates that an interrupt has been caused by active power no-load detected. 1 this function is not availab le in the ADE7566 and ade7569. 2 this function is not availab le in the ADE7566 and ade7166. table 40. interrupt status 2 sfr (mirqstm, 0xdd) bit interrupt flag description 7 cf2 logic 1 indicates that a pulse on cf2 has been issued. the flag is set even if cf2 pu lse output is not enabled by clearing bit 2 of the mode1 register. 6 cf1 logic 1 indicates that a pulse on cf1 has been issued. the flag is set even if cf1 pu lse output is not enabled by clearing bit 1 of the mode1 register. 5 vaeof logic 1 indicates that the vahr register has overflowed. 4 reof 1 logic 1 indicates that the varhr register has overflowed. 3 aeof logic 1 indicates that the watthr register has overflowed. 2 vaehf logic 1 indicates that the vahr register is half full. 1 rehf 1 logic 1 indicates that the varhr register is half full. 0 aehf logic 1 indicates that the watthr register is half full. 1 this function is not availab le in the ADE7566 and ade7166.
ADE7566/ade7569/ade7166/ade7169 rev. a | page 45 of 144 table 41. interrupt status 3 sfr (mirqsth, 0xde) bit interrupt flag description 7 reset indicates the end of a reset (for both software and hardware reset). 6 reserved. 5 wfsm logic 1 indicates that new data is present in the waveform registers (address 0xe2 to address 0xe7). 4 pki logic 1 indicates that current channel has exceeded the ipklvl value 3 pkv logic 1 indicates that voltage channel has exceeded the vpklvl value. 2 cycend logic 1 indicates the end of the energy accumulation over an integer number of half-line cycles. 1 zxto logic 1 indicates that no zero crossing on the line voltage happened for the last zxtout half-line cycles. 0 zx logic 1 indicates detection of a zero crossing in the voltage channel. table 42. interrupt enable 1 sfr (mirqenl, 0xd9) bit interrupt enable bit description 7 to 6 reserved reserved. 5 faultsign 1 when this bit is set, the faultsign bit set creates a pending ade interrupt to the 8052 core. 4 varsign 2 when this bit is set, the varsign flag set creates a pending ade interrupt to the 8052 core. 3 apsign when this bit is set, the apsign flag se t creates a pending ade interrupt to the 8052 core. 2 vanoload when this bit is set, the vanoload flag set creates a pending ade interrupt to the 8052 core. 1 rnoload 2 when this bit is set, the rnoload flag set creates a pending ade interrupt to the 8052 core. 0 apnoload when this bit is set, the apnoload flag set creates a pending ade interrupt to the 8052 core. 1 this function is not availab le in the ADE7566 and ade7569. 2 this function is not availab le in the ADE7566 and ade7166. table 43. interrupt enable 2 sfr (mirqenm, 0xda) bit interrupt enable bit description 7 cf2 when this bit is set, a cf2 pulse creates a pending ade interrupt to the 8052 core. 6 cf1 when this bit is set, a cf1 pulse creates a pending ade interrupt to the 8052 core. 5 vaeof when this bit is set, the vaeof flag se t creates a pending ade interrupt to the 8052 core. 4 reof 1 when this bit is set, the reof flag set cr eates a pending ade interrupt to the 8052 core. 3 aeof when this bit is set, the aeof flag set creates a pending ade interrupt to the 8052 core. 2 vaehf when this bit is set, the vaehf flag se t creates a pending ade interrupt to the 8052 core. 1 rehf 1 when this bit is set, the rehf flag set cr eates a pending ade interrupt to the 8052 core. 0 aehf when this bit is set, the aehf flag set creates a pending ade interrupt to the 8052 core. 1 this function is not availab le in the ADE7566 and ade7166.
ADE7566/ade7569/ade7166/ade7169 rev. a | page 46 of 144 table 44. interrupt enable 3 sfr (mirqenh, 0xdb) bit interrupt enable bit description 7 to 6 reserved. 5 wfsm when this bit is set, the wfsm flag se t creates a pending ade interrupt to the 8052 core. 4 pki when this bit is set, the pki flag set creates a pending ade interrupt to the 8052 core. 3 pkv when this bit is set, the pkv flag set creates a pending ade interrupt to the 8052 core. 2 cycend when this bit is set, the cycend flag set creates a pending ade interrupt to the 8052 core. 1 zxto when this bit is set, the zxto flag se t creates a pending ade interrupt to the 8052 core. 0 zx when this bit is set, the zx flag set creates a pending ade interrupt to the 8052 core. k v in v p 1 v n 1 00000000 76543210 gain[7:0] gain (k) selection v in 06353-018 analog inputs each ADE7566/ade7569/ade7166/ade7169 has two fully differential voltage input channels. the maximum differential input voltage for input pairs v p /v n and i p /i n is 0.4 v. for the ADE7566 and ade7569. for the ade7166 and ade7169, pga1 = 1 is not recommended because at full scale, when both i pa and i pb are 180 out of phase, the adc can be overranged. it is recommended, for these products, that pga1 = 2, 4, 8, or 16 be used. each analog input channel has a programmable gain amplifier (pga) with possible gain selections of 1, 2, 4, 8, and 16. the gain selections are made by writing to the gain register (see figure 40. pga in current channel 00000000 76543210 gain register* current and voltage channels pga control pga2 gain select 000 = 1 001 = 2 010 = 4 011 = 8 100 = 16 pga1 gain select 000 = 1 001 = 2 010 = 4 011 = 8 100 = 16 reserved *register contents show power-on defaults. addr: 0x1b 06353-019 cfsign_opt table 37 and figure 41 ). bit 0 to bit 2 select the gain for the pga in the current channel, and bit 5 to bit 7 select the gain for the pga in the voltage channel. for the ade7166 and ade7169, it is recommended that pga1 = 2, 4, 8, or 16 be used. figure 40 shows how a gain selection for the current channel is made using the gain register. figure 41. analog gain register
ADE7566/ade7569/ade7166/ade7169 rev. a | page 47 of 144 analog-to-digital conversion each ADE7566/ade7569/ade7166/ade7169 has two sigma- delta (-) analog-to-digital converters (adcs). the outputs of these adcs are mapped directly to waveform sampling sfrs (address 0xe2 to address 0xe7) and are used for energy measurement internal digital signal processing. in psm1 (battery mode) and psm2 (sleep mode), the adcs are powered down to minimize power consumption. for simplicity, the block diagram in figure 43 shows a first- order - adc. the converter is made up of the - modulator and the digital low-pass filter. a - ? modulator converts the input signal into a continuous serial stream of 1s and 0s at a rate determined by the sampling clock. in the ADE7566/ade7569/ade7166/ade7169, the sampling clock is equal to 4.096 mhz/5. the 1-bit dac in the feedback loop is driven by the serial data stream. the dac output is subtracted from the input signal. if the loop gain is high enough, the average value of the dac output (and, therefore, the bit stream) can approach that of the input signal level. for any given input value in a single sampling interval, the data from the 1-bit adc is virtually meaningless. only when a large number of samples are averaged is a meaningful result obtained. this averaging is carried into the second part of the adc, the digital low-pass filter. by averaging a large number of bits from the modulator, the low-pass filter can produce 24-bit data- words that are proportional to the input signal level. the - converter uses two techniques to achieve high resolution from what is essentially a 1-bit conversion technique. the first is oversampling. oversampling means that the signal is sampled at a rate (frequency) that is many times higher than the bandwidth of interest. for example, the sampling rate in the ADE7566/ ade7569/ade7166/ade7169 is 4.096 mhz/5 (819.2 khz), and the band of interest is 40 hz to 2 khz. oversampling has the effect of spreading the quantization noise (noise due to sampling) over a wider bandwidth. with the noise spread more thinly over a wider bandwidth, the quantization noise in the band of interest is lowered (see figure 42 ). however, oversampling alone is not efficient enough to improve the signal-to-noise ratio (snr) in the band of interest. for example, an oversampling ratio of four is required to increase the snr by only 6 db (1 bit). to keep the oversampling ratio at a reasonable level, it is possible to shape the quantization noise so that the majority of the noise lies at the higher frequencies. in the - modulator, the noise is shaped by the integrator, which has a high-pass-type response for the quantization noise. the result is that most of the noise is at the higher frequencies where it can be removed by the digital low-pass filter. this noise shaping is shown in figure 42 . 409.6 0 819.2 2 noise s ign a l digital filter antialias filter (rc) sampling frequency high resolution output from digital lpf shaped noise 409.6 0 819.2 2 noise s ign a l frequency (khz) frequency (khz) 06353-021 figure 42. noise reduction due to oversampling and noise shaping in the analog modulator + ? integrator v ref 1-bit dac digital low-pass filter 24 mclk/5 c r analog low-pass filter ... 10100101 ... latched comparator 06353-020 figure 43. first-order -? adc
ADE7566/ade7569/ade7166/ade7169 rev. a | page 48 of 144 409.6 0 819.2 2 frequency (khz) sampling frequency a liasing effects image frequencies 06353-022 antialiasing filter figure 43 also shows an analog low-pass filter (rc) on the input to the modulator. this filter is present to prevent aliasing, an artifact of all sampled systems. aliasing means that frequency components in the input signal to the adc, which are higher than half the sampling rate of the adc, appear in the sampled signal at a frequency below half the sampling rate. figure 44 illustrates the effect. frequency components (the black arrows) above half the sampling frequency (also know as the nyquist frequency, that is, 409.6 khz) ar e imaged or folded back down below 409.6 khz. this happens with all adcs regardless of the architecture. in the example shown, only frequencies near the sampling frequency (819.2 khz) move into the band of interest for metering (40 hz to 2 khz). this allows the use of a very simple lpf (low-pass filter) to attenuate high frequency (near 819.2 khz) noise and prevents distortion in the band of interest. figure 44. adc and signal processing in current channel outline dimensions adc transfer function both adcs in the ADE7566/ade7569/ade7166/ade7169 are designed to produce the same output code for the same input signal level. with a full-scale signal on the input of 0.4 v and an internal reference of 1.2 v, the adc output code is nominally 2,147,483 or 0x20c49b. the maximum code from the adc is 4,194,304; this is equivalent to an input signal level of 0.794 v. however, for specified performance, it is recommended that the full-scale input signal level of 0.4 v not be exceeded. for conventional current sensors, a simple rc filter (single-pole lpf) with a corner frequency of 10 khz produces an attenuation of approximately 40 db at 819.2 khz (see figure 44 ). the 20 db per decade attenuation is usually sufficient to eliminate the effects of aliasing for conventional current sensors. however, for a di/dt sensor such as a rogowski coil, the sensor has a 20 db per decade gain. this neutralizes the ?20 db per decade attenuation produced by one simple lpf. therefore, when using a di/dt sensor, care should be taken to offset the 20 db per decade gain. one simple approach is to cascade two rc filters to produce the ?40 db per decade attenuation needed. current channel adc figure 45 shows the adc and signal processing chain for the current channel. in waveform sampling mode, the adc outputs a signed, twos complement, 24-bit data-word at a maximum of 25.6 ksps (4.096 mhz/160). with the specified full-scale analog input signal of 0.4 v and pga1 = 1, the adc produces an output code that is approximately between 0x20c49b (+2,147,483d) and 0xdf3b65 (?2,147,483d). for inputs of 0.25 v, 0.125 v, 82.6 mv, and 31.3 mv with pga1 = 2, 4, 8, and 16, respectively, the adc produces an output code that is approximately between 0x28f5c2 (+2,684,354d) and 0xd70a3e (C2,684,354d). pga1 adc i pa i n i reference 1, 2, 4 8, 16 {gain[2:0]} hpf digital integrator* dt mode 1[5] current rms (i rms ) calculation waveform sample register active and reactive power calculation 0v v1 analog input range 0.25v, 0.125v, 62.5mv, 31.3mv current channel waveform data range 0x28f5c2 0x000000 0xd70a3e current channel waveform data range after integrator (50hz) 0x342cd0 0x000000 0xcbd330 current channel waveform data range after integrator (60hz) 0x2b7850 0x000000 0xd487b0 60hz 50hz * when digital integrator is enabled, full-scale output data is atte nuated depending on the signal frequency because the integrator has a ?20db/decade frequency response. when disabled, the output is not further attenuated. pga1 = 1 is not recommended in the ade7166 and ade7169. 06353-023 figure 45. adc and signal processing in current channel with pga1 = 1, 2, 4, 8, or 16 for ADE7566 and ade7569
ADE7566/ade7569/ade7166/ade7169 rev. a | page 49 of 144 pga1 adc i pa i bp i n i reference ibgain 1, 2, 4 8, 16 {gain[2:0]} hpf digital integrator* dt mode 1[5] current rms (i rms ) calculation waveform sample register active and reactive power calculation 0v v1 analog input range 0.25v, 0.125v, 62.5mv, 31.3mv current channel waveform data range 0x28f5c2 0x000000 0xd70a3e current channel waveform data range after integrator (50hz) 0x342cd0 0x000000 0xcbd330 current channel waveform data range after integrator (60hz) 0x2b7850 0x000000 0xd487b0 60hz 50hz *when digital integrator is enabled, full-scale output data is attenuated depending on the signal frequency because the integrator has a ?20db/decade frequency response. when disabled, the output is not further attenuated. 06353-117 pga1 adc hpf figure 46. adc and signal processing in current channel with pga1 = 2, 4, 8, or 16 for ade7166 and ade7169 analog input range hpf adc reference v2 0v 0.5v, 0.25v, 0.125v, 62.5mv, 31.3mv voltage rms (v rms ) calculation v p v n pga2 v2 voltage channel waveform data range 0xd70b 0x0000 0x28f5 a cti v e a nd re a cti v e power calculation lpf1 f ?3db = 63.7hz mode 1[6] zx signal data range for 60hz signal 0xe230 0x0000 0x1dd0 zx detection zx signal data range for 50hz signal 0xdfc9 0x0000 0x2037 voltage peak detect 1, 2, 4, 8, 16 {gain[7:5]} waveform sample register 06353-024 *when digital integrator is enabled, full-scale output data is attenuated depending on the signal frequency because the integrator has a ?20db/decade frequency response. when disabled, the output is not further attenuated. figure 47. adc and signal processing in voltage channel
ADE7566/ade7569/ade7166/ade7169 rev. a | page 50 of 144 voltage channel adc figure 47 shows the adc and signal processing chain for the voltage channel. in waveform sampling mode, the adc outputs a signed, twos complement, 24-bit data-word at a maximum of 25.6 ksps (mclk/160). the adc produces an output code that is approximately between 0x28f5 (+10,485d) and 0xd70b (?10,485d). channel sampling the waveform samples of the current adc and voltage adc can also be routed to the waveform registers to be read by the mcu core. the active, reactive, apparent power, and energy calculation remain uninterrupted during waveform sampling. when in waveform sampling mode, one of four output sample rates can be chosen by using the dtrt[1:0] bits of the wavmode register (see table 34 ) . the output sample rate can be 25.6 ksps, 12.8 ksps, 6.4 ksps, or 3.2 ksps. if the wfsm enable bit is set in the interrupt enable 3 sfr (mirqenh, 0xdb), the 8052 core has a pending ade interrupt. the sampled signals selected in the wavmode register are latched into the waveform sfrs when the waveform high byte (wav1h or wav2h) is read. the ade interrupt stays active until the wfsm status bit is cleared (see the energy measurement interrupts section). fault detection 1 the ade7166/ade7169 incorporate a fault detection scheme that warns of fault conditions and allows the ade7166/ade7169 to continue accurate measurement during a fault event. the ade7166/ade7169 do this by continuously monitoring both current inputs (i pa and i pb ). for ease of understanding, these currents are referred to as phase and neutral (return) currents. in the ade7166/ade7169, a fault condition is defined when the difference between i pa and i pb is greater than 6.25% of the active channel. if a fault condition is detected and the inactive channel is larger than the active channel, the ade7166/ade7169 automatically switch current measurement to the inactive channel. during a fault, the active, reactive, current rms and apparent powers are generated using the larger of the two currents. on power-up, i pa is the current input selected for active, reactive, and apparent power and irms calculations. to prevent false alarm, averaging is done for the fault detection, and a fault condition is detected approximately one second after the event. the fault detection is automatically disabled when the voltage signal is less than 0.3% of the full-scale input range. this eliminates false detection of a fault due to noise at light loads. because the ade7166/ade7169 look for a difference between the voltage signals on i pa and i pb , it is important that both current transducers be closely matched. channel selection indication the current channel selected for measurement is indicated by bit 7 (ichannel) in the accmode register (0x0f) . when this bit is cleared, i pa is selected and, when it is set, i pb is selected. the ade7166/ade7169 automatically switch from one channel to the other and report the channel configuration in the 1 this function is not availab le in the ADE7566 and ade7569. accmode register (0x0f) . the current channel selected for measurement can also be forced. setting the sel_i_ch[1:0] bits in the calmode register (0x3d) selects i pa and i pb , respectively. when both bits are cleared or set, the current channel used for measurement is selected automatically based on the fault detection. fault indication the ade7166/ade7169 provide an indication of the part going in or out of a fault condition. the new fault condition is indicated by the faultsign flag (bit 5) in the interrupt status 1 sfr (mirqstl, 0xdc) . when faultsign bit (bit 6) of the accmode register (0x0f) is cleared, the faultsign flag in the interrupt status 1 sfr (mirqstl, 0xdc) is set when the part is a entering fault condition or a normal condition. when the faultsign bit is set in the interrupt enable 1 sfr (mirqenl, 0xd9) , and the faultsign flag in the interrupt status 1 sfr (mirqstl, 0xdc) is set, the 8052 core has a pending ade interrupt. fault with active input greater than inactive input if i pa is the active current input (that is, being used for billing), and the voltage signal on i pb (inactive input) falls below 93.75% of i pa , and the faultsign bit (bit 6) of accmode register (0x0f) is cleared, the faultsign flag in the interrupt status 1 sfr (mirqstl, 0xdc) is set. both analog inputs are filtered and averaged to prevent false triggering of this logic output. as a consequence of the filtering, there is a time delay of approximately three seconds on the logic output after the fault event. the faultsign flag is independent of any activity. because i pa is the active input and it is still greater than i pb , billing is maintained on i pa ; that is, no swap to the i pb input occurs. i pa remains the active input. fault with inactive input greater than active input if the difference between i pb , the inactive input, and i pa , the active input (that is, being used for billing), becomes greater than 6.25% of i pb , and the faultsign bit (bit 6) of accmode register (0x0f) is cleared, the faultsign flag in the interrupt status 1 sfr (mirqstl, 0xdc) is set. the analog input i pb becomes the active input. again, a time constant of about three seconds is associated with this swap. i pa does not swap back to the active channel until i pa is greater than i pb and the difference between i pa and i pb in this orderbecomes greater than 6.25% of i pb . however, if faultsign bit (bit 6) of accmode register (0x0f) is set, the faultsign flag in the interrupt status 1 sfr (mirqstl, 0xdc) is set as soon as i pa is within 6.25% of ip b . this threshold eliminates potential chatter between i pa and i pb .
ADE7566/ade7569/ade7166/ade7169 rev. a | page 51 of 144 calibration concerns typically, when a meter is being calibrated, the voltage and current circuits are separated, as shown in figure 48. this means that current passes through only the phase or neutral circuit. figure 48 shows current being passed through the phase circuit. this is the preferred option because the ade7166/ ade7169 start billing on the input i pa on power-up. the phase circuit ct is connected to i pa in the diagram. because the current sensors are not perfectly matched, it is important to match current inputs. the ade7166/ade7169 provide a gain calibration register for i pb, ibgain (address 0x1c). ibgain is a 12-bit, signed, twos complement register that provides a gain resolution of 0.0244%/lsb. for calibration, a first measurement should be done on i pa by setting the sel_i_ch bits to 0b01 in the calmode register (0x3d). this measurement should be compared to the measurement on i pb . measuring i pb can be forced by setting sel_i_ch bits to 0b10 in the calmode register (0x3d). the gain error between these two measurements can be evaluated using () () () () a a b i t measuremen i t measuremen i t measuremen error ? = % the two channels i pa and i pb can then be matched by writing Cerror(%)/(1 + error (%)) 2 12 to the ibgain register. this matching adjustment is be valid for all energy measurements, active power, reactive power, i rms , and apparent power, made by the ade7166/ade7169. agnd i pb i n i pa r f r f c f c f ct ct r b r b 0v v a 0 i pb phase neutral r f r a v p r f v n c t c f v test current 240v rms 06353-025 figure 48. fault conditions for inactive input greater than active input di/dt current sensor and digital integrator for the ade7569/ade7169 a di/dt sensor, a feature available for the ad7569/ade7169 but not for the ad7566/ade7166, detects changes in the magnetic field caused by ac currents. figure 49 shows the principle of a di/dt current sensor. magnetic field created by current (directly proportional to current) + emf (electromotive force) ? induced by changes in magnetic flux density (di/dt) 06353-026 figure 49. principle of a di/dt current sensor the flux density of a magnetic field induced by a current is directly proportional to the magnitude of the current. the changes in the magnetic flux density passing through a conductor loop generate an electromotive force (emf) between the two ends of the loop. the emf is a voltage signal that is proportional to the di/dt of the current. the voltage output from the di/dt current sensor is determined by the mutual inductance between the current-carrying conductor and the di/dt sensor. the current signal needs to be recovered from the di/dt signal before it can be used. an integrator is therefore necessary to restore the signal to its original form. the ade7569/ade7169 have a built-in digital integrator to recover the current signal from the di/dt sensor. the digital integrator on the current channel is switched off by default when the ade7569/ade7169 are powered up. setting the inte bit in the mode1 register (0x0b) turns on the integrator. figure 50 to figure 53 show the magnitude and phase response of the digital integrator. frequency (hz) 10 gain (db) 0 ?10 ?20 ?30 ?40 ?50 100 1000 0 6353-027 figure 50. combined gain response of the digital integrator and phase compensator
ADE7566/ade7569/ade7166/ade7169 rev. a | page 52 of 144 frequency (hz) 10 2 10 3 06353-106 freq ? 88.0 phase (degrees) ?88.5 ?89.0 ?89.5 ?90.0 ?90.5 ?89.75 ?89.80 ?89.85 ?89.90 ?89.95 ?90.00 frequency (hz) phase (degrees) 40 45 70 50 55 60 65 ?90.05 ? 89.70 06353-030 figure 53. combined phase response of the digital integrator and phase compensator (40 hz to 70 hz) figure 51. combined phase response of the digital integrator and phase compensator note that the integrator has a ?20 db/dec attenuation and an approximately ?90 phase shift. when combined with a di/dt sensor, the resulting magnitude and phase response should be a flat gain over the frequency band of interest. the di/dt sensor has a 20 db/dec gain associated with it. it also generates significant high frequency noise. therefore, a more effective antialiasing filter is needed to avoid noise due to aliasing (see the frequency (hz) ? 1.0 ?6.0 40 70 45 gain (db) 50 55 60 65 ?1.5 ?2.0 ?2.5 ?3.5 ?4.5 ?5.5 ?3.0 ?4.0 ?5.0 06353-029 antialiasing filter section). when the digital integrator is switched off, the ade7569/ade7169 can be used directly with a conventional current sensor such as a current transformer (ct) or with a low resistance current shunt. figure 52. combined gain response of the digital integrator and phase compensator (40 hz to 70 hz)
ADE7566/ade7569/ade7166/ade7169 rev. a | page 53 of 144 power quality measurements zero-crossing detection each ADE7566/ade7569/ade7166/ade7169 has a zero- crossing detection circuit on the voltage channel. this zero crossing is used to produce a zero-crossing internal signal (zx) and is used in calibration mode. the zero-crossing is generated by default from the output of lpf1. this filter has a low cut-off frequency and is intended for 50 hz and 60 hz systems. if needed, this filter can be disabled to allow a higher frequency signal to be detected or to limit the group delay of the detection. if the voltage input fundamental frequency is below 60 hz, and a time delay in zx detection is acceptable, it is recommended to enable lpf1. enabling lpf1 limits the variability in the zx detection by eliminating the high frequency components. figure 54 shows how the zero-crossing signal is generated. 1, 2, 4, 8, 16 adc 2 reference lpf1 f ?3db = 63.7hz pga2 {gain [7:5]} v p v n v2 zero cross zx hpf mode 1[6] 43.24 @ 60hz 1.0 0.73 zx v2 lpf1 06353-031 figure 54. zero-crossing detection on the voltage channel the zero-crossing signal zx is generated from the output of lpf1 (bypassed or not). lpf1 has a single pole at 63.7 hz (at mclk = 4.096 mhz). as a result, there is a phase lag between the analog input signal v2 and the output of lpf1. the phase lag response of lpf1 results in a time delay of approximately 2 ms (@ 60 hz) between the zero crossing on the analog inputs of the voltage channel and zx detection. the zero-crossing detection also drives the zx flag in the interrupt status 3 sfr (mirqsth, 0xde). if the zx bit in the interrupt enable 3 sfr (mirqenh, 0xdb) is set, the 8052 core has a pending ade interrupt. the ade interrupt stays active until the zx status bit is cleared (see the energy measurement interrupts section). zero-crossing timeout the zero-crossing detection also has an associated timeout register, zxtout. this unsigned, 12-bit register is decremented (1 lsb) every 160/mclk seconds. the register is reset to its user programmed, full-scale value every time a zero crossing is detected on the voltage channel. the default power-on value in this register is 0xfff. if the internal register decrements to 0 before a zero crossing is detected in the interrupt status 3 sfr (mirqsth, 0xde), and the zxto bit in the interrupt enable 3 sfr (mirqenh, 0xdb) is set, the 8052 core has a pending ade interrupt. the ade interrupt stays active until the zxto status bit is cleared (see the energy measurement interrupts section). the zxout register (address 0x11) can be written to or read by the user (see the energy measurement register list section). the resolution of the register is 160/mclk seconds per lsb. thus, the maximum delay for an interrupt is 0.16 seconds (1/mclk 2 12 ) when mclk = 4.096 mhz. figure 55 shows the mechanism of the zero-crossing timeout detection when the line voltage stays at a fixed dc level for more than mclk/160 zxtout seconds. 12-bit internal register value zxtout zxto flag bit voltage channel 06353-032 figure 55. zero-crossing timeout detection period or frequency measurements the ADE7566/ade7569/ade7166/ade7169 provide the period or frequency measurement of the line. the period or frequency measurement is selected by clearing or setting the freqsel bit in the mode2 register (0x0c). the period/ frequency register, per_freq register (0x0a), is an unsigned 16-bit register that is updated every period. if lpf1 is enabled, a settling time of 1.8 seconds is associated with this filter before the measurement is stable. when the period measurement is selected, the measurement has a 2.44 s/lsb (4.096 mhz/10), which represents 0.014% when the line frequency is 60 hz. when the line frequency is 60 hz, the value of the period register is approximately 0d6827. the length of the register enables the measurement of line frequencies as low as 12.5 hz. the period register is stable at 1 lsb when the line is established and the measurement does not change. when the frequency measurement is selected, the measurement has a 0.0625 hz/lsb resolution when mclk = 4.096 mhz, which represents 0.104% when the line frequency is 60 hz. when the line frequency is 60 hz, the value of the frequency register is 0d960. the frequency register is stable at 4 lsb when the line is established and the measurement does not change.
ADE7566/ade7569/ade7166/ade7169 rev. a | page 54 of 144 pkv reset low when mirqsth sfr is read vpklvl[15:0] v 2 reset bit pkv in mirqsth sf r pkv interrupt flag 06353-034 line voltage sag detection in addition to detection of the loss of the line voltage signal (zero crossing), the ADE7566/ade7569/ade7166/ade7169 can also be programmed to detect when the absolute value of the line voltage drops below a certain peak value for a number of line cycles. this condition is illustrated in figure 56 . sag reset low when voltage channel exceeds saglvl [15:0] and sag flag reset full scale s aglvl [15:0] sag flag sagcyc [7:0] = 0x04 3 line cycles 06353-033 voltage channel figure 57. peak level detection figure 57 shows a line voltage exceeding a threshold that is set in the voltage peak register (vpklvl[15:0]). the voltage peak event is recorded by setting the pkv flag in the interrupt status 3 sfr (mirqsth, 0xde). if the pkv enable bit is set in the interrupt enable 3 sfr (mirqenh, 0xdb), the 8052 core has a pending ade interrupt. similarly, the current peak event is recorded by setting the pki flag in interrupt status 3 sfr (mirqsth, 0xde). the ade interrupt stays active until the pkv or pki status bit is cleared (see the figure 56. sag detection figure 56 shows the line voltage falling below a threshold that is set in the sag level register (saglvl[15:0]) for three line cycles. the quantities 0 and 1 are not valid for the sagcyc register, and the contents represent one more than the desired number of full line cycles. for example, when the sag cycle (sagcyc[7:0]) contains 0x04, fsag in the power management interrupt flag sfr (ipsmf, 0xf8) is set at the end of the third line cycle after the line voltage falls below the threshold. if the sag enable bit (esag) in the power management interrupt enable sfr (ipsme, 0xec) is set, the 8052 core has a pending power supply monitoring interrupt. the psm interrupt stays active until the esag bit is cleared (see the energy measurement interrupts section). peak level set the contents of the vpklvl and ipklvl registers are compared to the absolute value of the voltage and current channels 2 msbs, respectively. thus, for example, the nominal maximum code from the current channel adc with a full-scale signal is 0x28f5c2 (see the current channel adc section). therefore, writing 0x28f5 to the ipklvl register puts the current channel, peak detection level at full scale and sets the current peak detection to its least sensitive value. writing 0x00 puts the current channel detection level at 0. the detection is done by comparing the contents of the ipklvl register to the incoming current channel sample. the pki flag indicates that the peak level is exceeded. if the pki or pkv bit is set in the interrupt enable 3 sfr (mirqenh, 0xdb), the 8052 core has a pending ade interrupt. power supply monitor interrupt (psm) section). figure 56 in , the sag flag (fsag) is set on the fifth line cycle after the signal on the voltage channel first dropped below the threshold level. sag level set the 2-byte contents of the sag level register (saglvl, 0x14) are compared to the absolute value of the output from lpf1. therefore, when lpf1 is enabled, writing 0x2038 to the sag level register puts the sag detection level at full scale (see peak level record figure 56 ). writing 0x00 or 0x01 puts the sag detection level at 0. the sag level register is compared to the input of the zx detection, and detection is made when the contents of the sag level register are greater. each ADE7566/ade7569/ade7166/ade7169 records the maximum absolute value reached by the voltage and current channels in two different registers, ipeak and vpeak, respectively. each register is a 24-bit unsigned register that is updated each time the absolute value of the waveform sample from the corresponding channel is above the value stored in the vpeak or ipeak register. the contents of the vpeak register correspond to the maximum absolute value observed on the voltage channel input. the contents of ipeak and vpeak represent the maximum absolute value observed on the current and voltage input, respectively. reading the rstvpeak and rstipeak registers clears their respective contents after the read operation. peak detection the ADE7566/ade7569/ade7166/ade7169 can also be programmed to detect when the absolute value of the voltage or current channel exceeds a specified peak value. figure 57 illustrates the behavior of the peak detection for the voltage channel. both voltage and current channels are monitored at the same time.
ADE7566/ade7569/ade7166/ade7169 rev. a | page 55 of 144 phase compensation rms calculation the ADE7566/ade7569/ade7166/ade7169 must work with transducers that can have inherent phase errors. for example, a phase error of 0.1 to 0.3 is not uncommon for a current transformer (ct). these phase errors can vary from part to part, and they must be corrected to perform accurate power calculations. the errors associated with phase mismatch are particularly noticeable at low power factors. the ADE7566/ ade7569/ade7166/ade7169 provide a means of digitally calibrating these small phase errors. the part allows a small time delay or time advance to be introduced into the signal processing chain to compensate for small phase errors. because the compensation is in time, this technique should only be used for small phase errors in the range of 0.1 to 0.5. correcting large phase errors using a time shift technique can introduce significant phase errors at higher harmonics. the root mean square (rms) value of a continuous signal v(t) is defined as = t rms dttv t v 0 2 )( 1 (3) for time sampling signals, rms calculation involves squaring the signal, taking the average, and obtaining the square root. the ADE7566/ade7569/ade7166/ade7169 implement this method by serially squaring the input, averaging them, and then taking the square root of the average. the averaging part of this signal processing is done by implementing a low-pass filter (lpf3 in figure 59 , figure 61 , and figure 62 ). this lpf has a ?3 db cut-off frequency of 2 hz when mclk = 4.096 mhz. () )sin(2 tvtv ?= (4) the phase calibration register (phcal[7:0]) is a twos complement, signed, single-byte register that has values ranging from 0x82 (?126d) to 0x68 (+104d). where v is the rms voltage. ( tvvtv ?= 2cos )( 22 2 ) (5) the phcal register is centered at 0x40, meaning that writing 0x40 to the register gives 0 delay. by changing this register, the time delay in the voltage channel signal path can change from ?231.93 s to +48.83 s (mclk = 4.096 mhz). one lsb is equivalent to 1.22 s (4.096 mhz/5) time delay or advance. a line frequency of 60 hz gives a phase resolution of 0.026 at the fundamental (that is, 360 1.22 s 60 hz). when this signal goes through lpf3, the cos(2 t) term is attenu- ated and only the dc term v rms 2 goes through (see figure 59 ). v lpf3 input v 2 ( t ) = v 2 ? v 2 cos (2 t ) v 2 ( t ) = v 2 v ( t ) = 2 v sin( t ) 06353-036 figure 58 illustrates how the phase compensation is used to remove a 0.1 phase lead in the current channel due to the external transducer. to cancel the lead (0.1) in the current channel, a phase lead must also be introduced into the voltage channel. the resolution of the phase adjustment allows the introduction of a phase lead in increments of 0.026. the phase lead is achieved by introducing a time advance into the voltage channel. a time advance of 4.88 s is made by writing ?4 (0x3c) to the time delay block, thus reducing the amount of time delay by 4.88 s, or equivalently, a phase lead of approximately 0.1 at a line frequency of 60 hz (0x3c represents ?4 because the register is centered with 0 at 0x40). figure 59. rms signal processing the i rms signal can be read from the waveform register by setting the wavmode register (0x0d) and setting the wfsm bit in the interrupt enable 3 sfr (mirqenh, 0xdb). like the current and voltage channels waveform sampling modes, the waveform data is available at sample rates of 25.6 ksps, 12.8 ksps, 6.4 ksps, or 3.2 ksps. it is important to note that when the current input is larger than 40% of full scale, the i rms waveform sample register does not represent the true processed rms value. the rms value processed with this level of input is larger than the 24-bit read by the wave- form register, making the value read truncated on the high end. 110100 1 70 pga1 i pa i n i adc 1 hpf 24 pga2 v p v n v adc 2 24 lpf2 v i 60hz 0.1 i v channel 2 delay reduced by 4.48s (0.1lead at 60hz) 0x0b in phcal[7:0] phcal[7:0] ?231.93s to +48.83s 60hz 1 1 delay block 1.22s/lsb 06353-035 figure 58. phase calibration
ADE7566/ade7569/ade7166/ade7169 rev. a | page 56 of 144 current channel rms calculation each ADE7566/ade7569/ade7166/ade7169 simultaneously calculates the rms values for the current and voltage channels in different registers. figure 61 shows the detail of the signal processing chain for the rms calculation on the current channel. the current channel rms value is processed from the samples used in the current channel waveform sampling mode and is stored in an unsigned 24-bit register (i rms ). one lsb of the current channel rms register is equivalent to one lsb of a current channel waveform sample. the update rate of the current channel rms measurement is 4.096 mhz/5. to minimize noise in the reading of the register, the i rms register can also be configured to update only with the zero crossing of the voltage input. this configuration is done by setting the zxrms bit in the mode2 register (0x0c). with the specified full-scale analog input signal different pga1 values, the adc produces an output code that is approximately 0d2,147,483 (pga1 = 1) or 0d2,684,354 (pga1 = 2, 4, 8, or 16). see the current channel adc section. similarly, the equivalent rms value of a full-scale ac signal is 0d1,518,499 (0x172ba3) when pga = 1 and 0d1,898,124 (0x1cf68c) when pga1 = 2, 4, 8, or 16. the current rms measurement provided in the ADE7566/ade7569/ade7166/ade7169 is accurate to within 0.5% for signal inputs between full scale and full scale/500. the conversion from the register value to amps must be done externally in the microprocessor using an amps/lsb constant. current channel rms offset compensation the ADE7566/ade7569/ade7166/ade7169 incorporate a current channel rms offset compensation register (irmsos). this is a 12-bit signed register that can be used to remove offset in the current channel rms calculation. an offset can exist in the rms calculation due to input noises that are integrated into the dc component of v 2 (t). one lsb of the current channel rms offset is equivalent to 16,384 lsbs of the square of the current channel rms register. assuming that the maximum value from the current channel rms calculation is 0d1,898,124 with full-scale ac inputs, then 1 lsb of the current channel rms offset represents 0.23% of measurement error at ?60 db down of full scale. 32768 2 += irmsos ii 0 rms rms (6) where i rms0 is the rms measurement without offset correction. i rms (t) 0x00 + irmsos[11:0] i rms [23:0] 2 26 2 25 sgn 2 27 2 17 2 16 2 18 24 24 dt mode 1[5] current channel waveform data range with integrator off 0xd70a3e 0x000000 0x28f5c2 60hz 0xd487b0 0x2b7850 0x000000 current channel waveform data range with integrator on (60hz) hpf1 digital integrator* lpf3 0 6353-037 hpf hpf i pa i pb figure 60. ADE7566/ ade7569 current channel rms signal processing with pga1 = 1, 2, 4, 8, or 16
ADE7566/ade7569/ade7166/ade7169 rev. a | page 57 of 144 i rms (t) 0x00 + irmsos[11:0] i rms [23:0] 2 26 2 25 sgn 2 27 2 17 2 16 2 18 24 24 dt hpf mode 1[5] hpf current channel waveform data range with integrator off 0xd70a3e 0x000000 0x28f5c2 60hz 0xd487b0 i pa i pb 0x2b7850 0x000000 current channel waveform data range with integrator on (60hz) hpf1 digital integrator* lpf3 0 6353-116 ibgain figure 61. ade7166/ ade7169 current channel rms signal processing with pga1 = 2, 4, 8, or 16 v rms [23:0] lpf3 lpf1 v oltage channel 0x28f5c2 0x00 + + vrmos[11:0] v oltage signal (v(t)) 0x28f5 0x0 0xd70b 2 16 sgn 2 15 2 7 2 6 2 8 06353-038 figure 62. voltage channel rms signal processing
ADE7566/ade7569/ade7166/ade7169 rev. a | page 58 of 144 voltage channel rms calculation the average power over an integral number of line cycles (n) is given by the expression in equation 11. figure 62 shows details of the signal processing chain for the rms calculation on the voltage channel. the voltage channel rms value is processed from the samples used in the voltage channel waveform sampling mode and is stored in the unsigned 24-bit v rms register. = = nt vidttp nt p 0 )( 1 (11) where: t is the line cycle period. p is referred to as the active or real power. the update rate of the voltage channel rms measurement is mclk/5. to minimize noise in the reading of the register, the v rms register can also be configured to update only with the zero crossing of the voltage input. this configuration is done by setting the zxrms bit in the mode2 register (0x0c). note that the active power is equal to the dc component of the instantaneous power signal p(t) in equation 11, that is, vi. this is the relationship used to calculate active power in the ADE7566/ ade7569/ade7166/ade7169. the instantaneous power signal p(t) is generated by multiplying the current and voltage signals. the dc component of the instantaneous power signal is then extracted by lpf2 (low-pass filter) to obtain the active power information. this process is illustrated in with the specified full-scale ac analog input signal of 0.4 v, the output from the lpf1 in figure 62 swings between 0x28f5 and 0xd70b at 60 hz (see the volt age c hannel ad c section). the equivalent rms value of this full-scale ac signal is approximately 0d1,898,124 (0x1cf68c) in the v rms register. the voltage rms measurement provided in the ADE7566/ade7569/ade7166/ ade7169 is accurate to within 0.5% for signal input between full scale and full scale/20. the conversion from the register value to volts must be done externally in the microprocessor using a v/lsb constant. figure 63 . instantaneous power signal p(t) = v i ? v i cos(2 t) active real power signal = v i 0x19999a vi 0xccccd 0x00000 current i(t) = 2 i sin( t) voltage v(t) = 2 v sin( t) 06353-039 voltage channel rms offset compensation the ADE7566/ade7569/ade7166/ade7169 incorporate a voltage channel rms offset compensation register (vrmsos). this is a 12-bit signed register that can be used to remove offset in the voltage channel rms calculation. an offset can exist in the rms calculation due to input noises and dc offset in the input samples. one lsb of the voltage channel rms offset is equivalent to 64 lsbs of the rms register. assuming that the maximum value from the voltage channel rms calculation is 0d1,898,124 with full-scale ac inputs, then 1 lsb of the voltage channel rms offset represents 3.37% of measurement error at ?60 db down of full scale. figure 63. active power calculation because lpf2 does not have an ideal brick wall frequency response (see figure 64 v rms = v rms0 + 64 vrmsos (7) ), the active power signal has some ripple due to the instantaneous power signal. this ripple is sinusoidal and has a frequency equal to twice the line frequency. because of its sinusoidal nature, the ripple is removed when the active power signal is integrated to calculate energy (see the where v rms0 is the rms measurement without offset correction. active energy calculation section). active power calculation active power is defined as the rate of energy flow from source to load. it is the product of the voltage and current waveforms. the resulting waveform is called the instantaneous power signal and is equal to the rate of energy flow at every instant of time. the unit of power is the watt or joules/second. equation 10 gives an expression for the instantaneous power signal in an ac system. () )sin(2 tvtv ?= (8) () )sin(2 titi ?= (9) frequency (hz) ?24 1 (db) ?20 31 03 01 ?12 ?16 ?8 ?4 0 06353-040 where: v is the rms voltage. i is the rms current. 0 0 )()()( titvtp = figure 64. frequency response of lpf2 )2cos( )( tvivitp ?= (10)
ADE7566/ade7569/ade7166/ade7169 rev. a | page 59 of 144 active power gain calibration active power sign detection figure 65 shows the signal processing chain for the active power calculation in the ADE7566/ade7569/ade7166/ade7169. as explained previously, the active power is calculated by filtering the output of the multiplier with a low-pass filter. note that when reading the waveform samples from the output of lpf2, the gain of the active energy can be adjusted by using the multiplier and watt gain register (wgain[11:0]). the gain is adjusted by writing a twos complement 12-bit word to the watt gain register. equation 12 shows how the gain adjustment is related to the contents of the watt gain register. the ADE7566/ade7569/ade7166/ade7169 detect a change of sign in the active power. the apsign flag in the interrupt status 1 sfr (mirqstl, 0xdc) records when a change of sign has occurred according to bit apsign in the accmode register (0x0f). if the apsign flag is set in the interrupt enable 1 sfr (mirqenl, 0xd9), the 8052 core has a pending ade interrupt. the ade interrupt stays active until the apsign status bit is cleared (see the energy measurement interrupts section). when apsign in the accmode register (0x0f) is cleared (default), the apsign flag in the interrupt status 1 sfr (mirqstl, 0xdc) is set when a transition from positiveCto- negative active power has occurred. ? ? ? ? ? ? ? ? ? ? ? ? ? ? + = 12 2 1 wgain power active wgain output (12) for example, when 0x7ff is written to the watt gain register, the power output is scaled up by 50% (0x7ff = 2047d, 2047/2 12 = 0.5). similarly, 0x800 = ?2048d (signed, twos complement) and power output is scaled by C50%. each lsb scales the power output by 0.0244%. the minimum output range is given when the watt gain register contents are equal to 0x800 and the maximum range is given by writing 0x7ff to the watt gain register. this can be used to calibrate the active power (or energy) calculation in the ADE7566/ade7569/ade7166/ ade7169. when apsign in the accmode register (0x0f) is set, the apsign flag in the mirqstl sfr is set when a transition from negative to positive active power occurrs. active power no-load detection the ADE7566/ade7569/ade7166/ade7169 include a no- load threshold feature on the active energy that eliminates any creep effects in the meter. the part accomplishes this by not accumulating energy if the multiplier output is below the no- load threshold. when the active power is below the no-load threshold, the apnoload flag in the interrupt status 1 sfr (mirqstl, 0xdc) is set. if the apnoload bit is set in the interrupt enable 1 sfr (mirqenl, 0xd9), the 8052 core has a pending ade interrupt. the ade interrupt stays active until the apnoload status bit is cleared (see the active power offset calibration the ADE7566/ade7569/ade7166/ade7169 also incorporate an active power offset register (wattos[15:0]). it is a signed, twos complement, 16-bit register that can be used to remove offsets in the active power calculation (see energy measurement interrupts figure 63 ). an offset can exist in the power calculation due to crosstalk between channels on the pcb or in the ic itself. the offset calibration allows the contents of the active power register to be maintained at 0 when no power is being consumed. section). the no-load threshold level is selectable by setting the apnoload bits in the nlmode register (0x0e). setting these bits to 0b00 disables the no-load detection, and setting them to 0b01, 0b10, or 0b11 sets the no-load detection threshold to 0.015%, 0.0075%, or 0.0037% of the multipliers full-scale output frequency, respectively. the iec 62053-21 specification states that the meter must start up with a load equal to or less than 0.4% i pb , which translates to .0167% of the full-scale output frequency of the multiplier. the 256 lsbs (wattos = 0x0100) written to the active power offset register are equivalent to 1 lsb in the waveform sample register. assuming the average value, output from lpf2 is 0xccccd (838,861d) when inputs on the voltage and current channels are both at full scale. at ?60 db down on the current channel (1/1000 of the current channel full-scale input), the average word value output from lp f2 is 838.861 (838,861/1,000). one lsb in the lpf2 output has a measurement error of 1/838.861 100% = 0.119% of the average value. the active power offset register has a resolution equal to 1/256 lsb of the waveform register. therefore, the power offset correction resolution is 0.000464%/lsb (0.119%/256) at ?60 db.
ADE7566/ade7569/ade7166/ade7169 rev. a | page 60 of 144 active energy calculation as stated in the active power calculation section, power is defined as the rate of energy flow. this relationship can be expressed mathematically in equation 13. dt de p = (13) where: p is power. e is energy. conversely, energy is given as the integral of power. = dttpe )( (14) the ADE7566/ade7569/ade7166/ade7169 achieve the integration of the active power signal by continuously accumu- lating the active power signal in an internal, nonreadable, 49-bit energy register. the register (watthr[23:0]) represents the upper 24 bits of this internal register. this discrete time accumulation or summation is equivalent to integration in continuous time. equation 15 expresses the relationship. ? ? ? ? ? ? == = 1 0 )(lim)( n t tntp dttpe (15) where: n is the discrete time sample number. t is the sample period. the discrete time sample period (t) for the accumulation register in the ADE7566/ade7569/ade7166/ade7169 is 1.22 s (5/mclk). in addition to calculating the energy, this integration removes any sinusoidal components that may be in the active power signal. shows this discrete time integration or accumulation. the active power signal in the waveform register is continuously added to the internal active energy register. the active energy accumulation depends on the setting of the poam and absam bits in the accmode register (0x0f). when both bits are cleared, the addition is signed and, therefore, negative energy is subtracted from the active energy contents. when both bits are set, the ADE7566/ade7569/ade7166/ ade7169 are set to be in the more restrictive mode, the positive- only accumulation mode. when poam in the accmode register (0x0f) is set, only positive power contributes to the active energy accumulation. when absam in the accmode register (0x0f) is set, the absolute active power is used for the active energy accumulation (see the watt ab s o lute ac c u mu l at i o n mo d e section). the output of the multiplier is divided by the value in the wdiv register. if the value in the wdiv register is equal to 0, the internal active energy register is divided by 1. wdiv is an 8-bit unsigned register. after dividing by wdiv, the active energy is accumulated in a 49-bit internal energy accumulation register. the upper 24 bits of this register are accessible through a read to the active energy register (watthr[23:0]). a read to the rwatthr register returns the content of the watthr register, and the upper 24 bits of the internal register are cleared. as shown in figure 65 , the active power signal is accumulated in an internal 49-bit signed register. the active power signal can be read from the waveform register by setting the wavmode register (0x0d) and setting the wfsm bit in the interrupt enable 3 sfr (mirqenh, 0xdb). like the current and voltage channels waveform sampling modes, the waveform data is available at sample rates of 25.6 ksps, 12.8 ksps, 6.4 ksps, or 3.2 ksps. figure 65 wgain[11:0] wdiv[7:0] lpf2 current channel v oltage c hannel output lpf2 time (nt) 5 clkin t active power signal + + watthr[23:0] outputs from the lpf2 are accumulated (integrated) in the internal active energy register upper 24 bits are accessible through watthr[23:0] register 23 0 48 0 % wattos[15:0] 2 6 sgn 2 5 2 ?6 2 ?7 2 ?8 + + for waveform sampling to digital-to-frequency converter waveform register values 0 6353-041 figure 65. active energy calculation
ADE7566/ade7569/ade7166/ade7169 rev. a | page 61 of 144 figure 66 shows this energy accumulation for full-scale signals (sinusoidal) on the analog inputs. the three displayed curves illustrate the minimum period of time it takes the energy register to roll over when the active power gain register contents are 0x7ff, 0x000, and 0x800. the watt gain register is used to carry out power calibration in the ADE7566/ade7569/ade7166/ ade7169. as shown, the fastest integration time occurs when the watt gain register is set to maximum full scale, that is, 0x7ff. when wdiv is set to a value other than 0, the integration time varies, as shown in equation 17. time = time wdiv = 0 wdiv (17) active energy ac cumulation modes watt sig n e d ac c u mu l ati on mo d e the ADE7566/ade7569/ade7166/ade7169 active energy default accumulation mode is a watt-signed accumulation based on the active power information. 0x00,0000 0x7f,fff f 0x3f,fff f 0x40,0000 0x80,0000 watthr[23:0] 6.82 3.41 10.2 13.7 time (minutes) wgain = 0x7ff wgain = 0x000 wgain = 0x800 0 6353-042 watt positive-only accumulation mode the ADE7566/ade7569/ade7166/ade7169 are placed in watt positive-only accumulation mode by setting the poam bit in the accmode register (0x0f). in this mode, the energy accumulation is only done for positive power, ignoring any occurrence of negative power above or below the no-load threshold (see figure 67 ). the cf pulse also reflects this accumulation method when in this mode. the default setting for this mode is off. detection of the transitions in the direction of power flow and detection of no-load threshold are active in this mode. pos pos interrupt status registers neg apsign flag no-load threshold active power no-load threshold active energy 0 6353-043 figure 66. energy register rollov er time for full-scale power (minimum and maximum power gain) note that the energy register contents roll over to full-scale negative (0x800000) and continue to increase in value when the power or energy flow is positive (see figure 66 ). conversely, if the power is negative, the energy register underflows to full- scale positive (0x7fffff) and continues to decrease in value. by using the interrupt enable register, the ADE7566/ade7569/ ade7166/ade7169can be configured to issue an ade interrupt to the 8052 core when the active energy register is half full (positive or negative) or when an overflow or underflow occurs. integration time under stea dy load: active energy as mentioned in the active energy calculation section, the discrete time sample period (t) for the accumulation register is 1.22 s (5/clkin). with full-scale sinusoidal signals on the analog inputs and the wgain register set to 0x000, the average word value from each lpf2 is 0xccccd (see figure 67. energy accumulation in positive-only accumulation mode watt absolute accumulation mode the ADE7566/ade7569/ade7166/ade7169 are placed in watt-absolute accumulation mode by setting the absam bit in the accmode register (0x0f). in this mode, the energy accumulation is done using the absolute active power, ignoring any occurrence of power below the no-load threshold (see figure 63 ). the maximum positive value that can be stored in the internal 49- bit register is 2 48 (or 0xffff,ffff,ffff) before it overflows. the integration time under these conditions when wdiv = 0 is calculated in the following equation: figure 68 ). the cf pulse also reflects this accumulation method when in this mode. the default setting for this mode is off. detection of the transitions in the direction of power flow, and detection of no-load threshold are active in this mode. time = min82.6sec6.409s22.1 xccccd0 ffffffff, xffff,0 = =? (16)
ADE7566/ade7569/ade7166/ade7169 rev. a | page 62 of 144 pos pos interrupt status registers neg apsign flag no-load threshold active power no-load threshold a ctive energy apnoload apnoload 06353-044 line cycle active energy accumulation mode in line cycle active energy accumulation mode, the energy accumu- lation of the ADE7566/ade7569/ade7166/ade7169 can be synchronized to the voltage channel zero crossing so that active energy can be accumulated over an integral number of half-line cycles. the advantage of summing the active energy over an integer number of line cycles is that the sinusoidal component in the active energy is reduced to 0. this eliminates any ripple in the energy calculation. energy is calculated more accurately and more quickly because the integration period can be shortened. by using this mode, the energy calibration can be greatly simplified, and the time required to calibrate the meter can be significantly reduced. in the line cycle active energy accumulation mode, the ADE7566/ade7569/ade7166/ade7169 accumulate the active power signal in the lwatthr register for an integral number of line cycles, as shown in figure 69 . the number of half-line cycles is specified in the lincyc register. figure 68. energy accumulation in absolute accumulation mode the ADE7566/ade7569/ade7166/ade7169 can accumulate active power for up to 65,535 half-line cycles. because the active power is integrated on an integral number of line cycles, the cycend flag in the interrupt status 3 sfr (mirqsth, 0xde) is set at the end of an active energy accumulation line cycle. if the cycend enable bit in the interrupt enable 3 sfr (mirqenh, 0xdb) is set, the 8052 core has a pending ade interrupt. the ade interrupt stays active until the cycend status bit is cleared (see the active energy pulse output all of the ADE7566/ade7569/ade7166/ade7169 circuitry has a pulse output whose frequency is proportional to active power (see the active power calculation section). this pulse frequency output uses the calibrated signal from the wgain register output, and its behavior is consistent with the setting of the active energy accumulation mode in the accmode register (0x0f). the pulse output is active low and should be preferably connected to an led as shown in energy measurement interrupts section). another calibration cycle starts as soon as the cycend flag is set. if the lwatthr register is not read before a new cycend flag is set, the lwatthr register is overwritten by a new value. figure 79 . wdiv[7:0] wattos[15:0] wgain[11:0] lpf1 + + lwatthr[23:0] active energy is accumulated in the internal register, and the lwatthr register is updated at the end of the lincyc half-line cycles output from lpf2 from voltage channel adc 23 0 lincyc[15:0] 48 0 % zero-crossing detection calibration control to digital-to-frequency converter 06353-046 figure 69. line cycle active energy accumulation
ADE7566/ade7569/ade7166/ade7169 rev. a | page 63 of 144 when a new half-line cycle is written in the lincyc register, the lwatthr register is reset, and a new accumulation starts at the next zero crossing. the number of half-line cycles is then counted until lincyc is reached. this implementation provides a valid measurement at the first cycend interrupt after writing to the lincyc register (see )sin(2)( tvtv + = (21) )sin(2)( titi = ? ? ? ? ? ? + = 2 sin2)( titi (22) figure 70 ). the line active energy accumulation uses the same signal path as the active energy accumulation. the lsb size of these two registers is equivalent. where: is the phase difference between the voltage and current channel. v is the rms voltage. i is the rms current. lincyc value cycend irq lwatthr register 06353-045 q ( t ) = v ( t ) i ( t ) (23) q ( t ) = vi sin ( ) + vi sin )2( + t the average reactive power over an integral number of lines (n) is given in equation 24. = = nt vidttq nt q 0 )sin()( 1 (24) figure 70. energy accumulation when lincyc changes where: t is the line cycle period. q is referred to as the reactive power. from the information in equation 10 and equation 11, () () dtft f vi dtvite nt nt ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? + ?= 2cos 9.8 1 0 2 0 (18) note that the reactive power is equal to the dc component of the instantaneous reactive power signal q(t) in equation 23. the instantaneous reactive power signal q(t) is generated by multiplying the voltage and current channels. in this case, the phase of the current channel is shifted by 90. the dc component of the instantaneous reactive power signal is then extracted by a low-pass filter to obtain the reactive power information (see where: n is an integer. t is the line cycle period. because the sinusoidal component is integrated over an integer number of line cycles, its value is always 0. therefore, figure 71 ). 0 0 += nt vidte (19) e ( t ) = vint (20) in addition, the phase-shifting filter has a non-unity magnitude response. because the phase-shifted filter has a large attenuation at high frequency, the reactive power is primarily for calculation at line frequency. the effect of harmonics is largely ignored in the reactive power calculation. note that, because of the magnitude characteristic of the phase shifting filter, the weight of the reactive power is slightly different from the active power calculation (see the note that in this mode, the 16-bit lincyc register can hold a maximum value of 65,535. in other words, the line energy accumulation mode can be used to accumulate active energy for a maximum duration of over 65,535 half-line cycles. at a 60 hz line frequency, it translates to a total duration of 65,535/120 hz = 546 sec. energy register scaling section). the frequency response of the lpf in the reactive signal path is identical to the one used for lpf2 in the average active power calculation. because lpf2 does not have an ideal brick wall frequency response (see reactive power calculation for the ade7569/ade7169 figure 64 ), the reactive power signal has some ripple due to the instantaneous reactive power signal. this ripple is sinusoidal and has a frequency equal to twice the line frequency. because the ripple is sinusoidal in nature, it is removed when the reactive power signal is integrated to calculate energy. reactive power, a function available for the ade7569/ade7169 but not for the ADE7566/ade7166, is defined as the product of the voltage and current waveforms when one of these signals is phase-shifted by 90. the resulting waveform is called the instantaneous reactive power signal. equation 23 gives an expression for the instantaneous reactive power signal in an ac system when the phase of the current channel is shifted by 90. the reactive power signal can be read from the waveform register by setting the wavmode register (0x0d) and the wfsm bit in the interrupt enable 3 sfr (mirqenh, 0xdb). like the current and voltage channels waveform sampling modes, the waveform data is available at sample rates of 25.6 ksps, 12.8 ksps, 6.4 ksps, or 3.2 ksps.
ADE7566/ade7569/ade7166/ade7169 rev. a | page 64 of 144 reactive power gain calibration figure 71 shows the signal processing chain for the ade7569/ade7169 reactive power calculation. as explained in the reactive power calculation for the ade7569 /ade7169 section, the reactive power is calculated by applying a low-pass filter to the instantaneous reactive power signal. note that, when reading the waveform samples from the output of lpf2, the gain of the reactive energy can be adjusted by using the multiplier and by writing a twos complement, 12-bit word to the var gain register (vargain[11:0]). equation 25 shows how the gain adjustment is related to the contents of the watt gain register. output vargain = ? ? ? ? ? ? ? ? ? ? ? ? + 12 2 1 vargain power reactive (25) the resolution of the vargain register is the same as the wgain register (see the active power gain calibration section). vargain can be used to calibrate the reactive power (or energy) calculation in the ade7569/ade7169. reactive power offset calibration the ade7569/ade7169 also incorporate a reactive power offset register (varos[15:0]). this is a signed, twos complement, 16-bit register that can be used to remove offsets in the reactive power calculation (see figure 71 ). an offset can exist in the reactive power calculation due to crosstalk between channels on the pcb or in the ic itself. the offset calibration allows the contents of the reactive power register to be maintained at 0 when no power is being consumed. the 256 lsbs (varos = 0x100) written to the reactive power offset register are equivalent to 1 lsb in the wavmode register. sign of reactive power calculation note that the average reactive power is a signed calculation. the phase shift filter has ?90 phase shift when the integrator is enabled, and +90 phase shift when the integrator is disabled. table 45 summarizes the relationship of the phase difference between the voltage and the current and the sign of the resulting va r c a l c u l a t i o n . table 45. sign of reactive power calculation angle integrator sign between 0 to +90 off positive between C90 to 0 off negative between 0 to +90 on positive between C90 to 0 on negative reactive power sign detection the ade7569/ade7169 detect a change of sign in the reactive power. the varsign flag in the interrupt status 1 sfr (mirqstl, 0xdc) records when a change of sign has occurred according to the varsign bit in the accmode register (0x0f). if the varsign bit is set in the interrupt enable 1 sfr (mirqenl, 0xd9), the 8052 core has a pending ade interrupt. the ade interrupt stays active until the varsign status bit is cleared (see the energy measurement interrupts section). when varsign in the accmode register (0x0f) is cleared (default), the varsign flag in the interrupt status 1 sfr (mirqstl, 0xdc) is set when a transition from positive to negative reactive power occurrs. when varsign in the accmode register (0x0f) is set, the varsign flag in the interrupt status 1 sfr (mirqstl, 0xdc) is set when a transition from negative to positive reactive power occurrs. reactive power no-load detection the ade7569/ade7169 include a no-load threshold feature on the reactive energy that eliminates any creep effects in the meter. the ade7569/ade7169 accomplish this by not accumulating reactive energy when the multiplier output is below the no-load threshold. when the reactive power is below the no-load threshold, the rnoload flag in the interrupt status 1 sfr (mirqstl, 0xdc) is set. if the rnoload bit is set in the interrupt enable 1 sfr (mirqenl, 0xd9), the 8052 core has a pending ade interrupt. the ade interrupt stays active until the rnoload status bit is cleared (see the energy measurement interrupts section). the no-load threshold level is selectable by setting the varnoload bits in the nlmode register (0x0e). setting these bits to 0b00 disables the no-load detection, and setting them to 0b01, 0b10, or 0b11 sets the no-load detection threshold to 0.015%, 0.0075%, and 0.0037% of the full-scale output frequency of the multiplier, respectively. reactive energy calculation for the ade7569/ade7169 as for active energy, the ade7569/ade7169 achieve the integration of the reactive power signal by continuously accumulating the reactive power signal in an internal, nonreadable, 49-bit energy register. the reactive energy register (varhr[23:0]) represents the upper 24 bits of this internal register. the varhr register and its function are available for the ade7569/ade7169 but not for the ADE7566/ade7166. the discrete time sample period (t) for the accumulation register in the ade7569/ade7169 is 1.22 s (5/mclk). as well as calculating the energy, this integration removes any sinusoidal components that may be in the active power signal. figure 71 shows this discrete time integration or accumulation. the reactive power signal in the waveform register is continuously added to the internal reactive energy register. the reactive energy accumulation depends on the setting of the savarm and absvarm bits in the accmode register (0x0f). when both bits are cleared, the addition is signed and, therefore, negative energy is subtracted from the reactive energy contents. when both bits are set, the ade7569/ade7169 are set to be in the more restrictive mode, the absolute accumulation mode.
ADE7566/ade7569/ade7166/ade7169 rev. a | page 65 of 144 as shown in when savarm in the accmode register (0x0f) is set, the reactive power is accumulated depending on the sign of the active power. when active power is positive, the reactive power is added as it is to the reactive energy register. when active power is negative, the reactive power is subtracted from the reactive energy accumulator (see the figure 71 , the reactive power signal is accumulated in an internal 49-bit signed register. the reactive power signal can be read from the waveform register by setting the wavmode register (0x0d) and setting the wfsm bit in the interrupt enable 3 sfr (mirqenh, 0xdb). like the current and voltage channel waveform sampling modes, the waveform data is available at sample rates of 25.6 ksps, 12.8 ksps, 6.4 ksps, or 3.2 ksps. va r a nt i t a mp e r accumulation mode section). figure 66 shows this energy accumulation for full-scale signals (sinusoidal) on the analog inputs. these curves also apply for the reactive energy accumulation. when absvarm in the accmode register (0x0f) is set, the absolute reactive power is used for the reactive energy accumu- lation (see the var absolute accumulation mode section). the output of the multiplier is divided by vardiv. if the value in the vardiv register is equal to 0, the internal reactive energy register is divided by 1. vardiv is an 8-bit, unsigned register. after dividing by vardiv, the reactive energy is accumulated in a 49-bit internal energy accumulation register. the upper 24 bits of this register are accessible through a read to the reactive energy register (varhr[23:0]). a read to the rvarhr register returns the content of the varhr register, and the upper 24 bits of the internal register are cleared. note that the energy register contents roll over to full-scale negative (0x800000) and continue to increase in value when the power or energy flow is positive. conversely, if the power is negative, the energy register underflows to full-scale positive (0x7fffff) and continues to decrease in value. by using the interrupt enable register, the ade7569/ade7169 can be configured to issue an ade interrupt to the 8052 core when the reactive energy register is half-full (positive or negative) or when an overflow or underflow occurs. vargain[11:0] vardiv[7:0] lpf2 current channel voltage channel output lpf2 time (nt) 5 clkin t reactive power signal + + varhr[23:0] upper 24 bits are accessible through varhr[23:0] register 23 0 48 0 waveform register values % varos[15:0] 2 6 sgn 2 5 2 ?6 2 ?7 2 ?8 + + for waveform sampling hpf 2 phcal[7:0] 90 phase shifting filter 06353-047 outputs from the lpf2 are accumulated (integrated) in the internal reactive energy register to digital-to-frequency converter figure 71. reactive energy calculation
ADE7566/ade7569/ade7166/ade7169 rev. a | page 66 of 144 integration time under stea dy load: reactive energy as mentioned in the active energy calculation section, the discrete time sample period (t) for the accumulation register is 1.22 s (5/mclk). with full-scale sinusoidal signals on the analog inputs and the vargain and vardiv registers set to 0x000, the integration time before the reactive energy register overflows is calculated in equation 26. time = min82.6sec6.409s22.1 0xccccd ffffffff, 0xffff, = =? (26) when vardiv is set to a value different from 0, the integration time varies, as shown in equation 27. vardiv time time wdiv = = 0 (27) pos pos interrupt status registers neg apsign flag active power no-load threshold no-load threshold reactive energy no-load threshold reactive power no-load threshold 0 6353-048 reactive energy accumulation modes va r s i g n e d ac c u m u l a t i o n m o d e the ade7569/ade7169 reactive energy default accumulation mode is a signed accumulation based on the reactive power information. var antitamper accumulation mode the ade7569/ade7169 are placed in var antitamper accumulation mode by setting the savarm bit in the accmode register (0x0f). in this mode, the reactive power is accumulated depending on the sign of the active power. when active power is positive, the reactive power is added as it is to the reactive energy register. when active power is negative, the reactive power is subtracted from the reactive energy accumulator (see figure 72. reactive energy accumulation in antitamper accumulation mode figure 72 ). the cf pulse also reflects this accumulation method when in this mode. the default setting for this mode is off. transitions in the direction of power flow and no-load threshold are active in this mode.
ADE7566/ade7569/ade7166/ade7169 rev. a | page 67 of 144 line cycle reactive energy accumulation mode var absolute accumulation mode in line cycle reactive energy accumulation mode, the energy accumulation of the ade7569/ade7169 can be synchronized to the voltage channel zero crossing so that reactive energy can be accumulated over an integral number of half-line cycles. the advantage of this mode is similar to the ones described in the the ade7569/ade7169 are placed in absolute accumulation mode by setting the absvarm bit in the accmode register (0x0f). in absolute accumulation mode, the reactive energy accumulation is done by using the absolute reactive power and ignoring any occurrence of power below the no-load threshold for the active energy (see line cycle active energy accumulation mode section. figure 68 ). the cf pulse also reflects this accumulation method when in the absolute accumulation mode. the default setting for this mode is off. transitions in the direction of power flow and no-load threshold are active in this mode. in line cycle active energy accumulation mode, the ade7569/ade7169 accumulate the reactive power signal in the lvarhr register for an integral number of line cycles, as shown in figure 74 . the number of half-line cycles is specified in the lincyc register. the ade7569/ade7169 can accumulate active power for up to 65,535 half-line cycles. reactive energy no-load threshold no-load threshold reactive power 0 6353-049 because the reactive power is integrated on an integral number of line cycles, the cycend flag in the interrupt status 3 sfr (mirqsth, 0xde) is set at the end of an active energy accumulation line cycle. if the cycend enable bit in the interrupt enable 3 sfr (mirqenh, 0xdb) is set, the 8052 core has a pending ade interrupt. the ade interrupt stays active until the cycend status bit is cleared (see the energy measurement interrupts section). another calibration cycle starts as soon as the cycend flag is set. if the lvarhr register is not read before a new cycend flag is set, the lvarhr register is overwritten by a new value. figure 73. reactive energy accumulation in absolute accumulation mode reactive energy pulse output when a new half-line cycle is written in the linecyc register, the lvarhr register is reset, and a new accumulation starts at the next zero crossing. the number of half-line cycles is then counted until lincyc is reached. this implementation provides a valid measurement at the first cycend interrupt after writing to the lincyc register. the line reactive energy accumulation uses the same signal path as the reactive energy accumulation. the lsb size of these two registers is equivalent. the ade7569/ade7169 provide all the circuitry with a pulse output whose frequency is proportional to reactive power (see the energy-to-frequency conversion section). this pulse frequency output uses the calibrated signal after vargain, and its behavior is consistent with the setting of the reactive energy accumulation mode in the accmode register (0x0f). the pulse output is active low and should preferably be connected to an led, as shown in figure 79 . lpf1 + + output from lpf2 from voltage channel adc 23 0 lincyc[15:0] 48 0 % zero-crossing detection lvarhr[23:0] calibration control vardiv[7:0] varos[15:0] vargain[11:0] 06353-050 to digital-to-frequency converter active energy is accumulated in the internal register, and the lwatthr register is updated at the end of the lincyc half-line cycles figure 74. line cycle reactive energy accumulation mode
ADE7566/ade7569/ade7166/ade7169 rev. a | page 68 of 144 the gain of the apparent energy can be adjusted by using the multiplier and by writing a twos complement, 12-bit word to the vagain register (vagain[11:0]). equation 32 shows how the gain adjustment is related to the contents of the vagain register. apparent power calculation apparent power is defined as the maximum power that can be delivered to a load. v rms and i rms are the effective voltage and current delivered to the load, respectively. therefore, the apparent power (ap) = v rms i rms . this equation is independent from the phase angle between the current and the voltage. output vagain = ? ? ? ? ? ? ? ? ? ? ? ? + 12 2 1 vagain power apparent (32) equation 31 gives an expression of the instantaneous power signal in an ac system with a phase shift. () 2 sin( ) rms vt v t = (28) () )sin(2 + = titi rms (29) )()()( titvtp = (30) ( ) )2cos( )cos( + ? = tiv ivtp rmsrms rmsrms (31) for example, when 0x7ff is written to the vagain register, the power output is scaled up by 50% (0x7ff = 2047d, 2047/2 12 = 0.5). similarly, 0x800 = C2047d (signed twos complement) and power output is scaled by C50%. each lsb represents 0.0244% of the power output. the apparent power is calculated with the current and voltage rms values obtained in the rms blocks of the ADE7566/ade7569/ade7166/ade7169. apparent power o ffset calibration figure 75 illustrates the signal processing for the calculation of the apparent power in the ADE7566/ade7569/ade7166/ ade7169. each rms measurement includes an offset compensation register to calibrate and eliminate the dc component in the rms value (see the current channel rms calculation section and the volt age channel rms calculation the apparent power signal can be read from the waveform register by setting the wavmode register (0x0d) and setting the wfsm bit in the interrupt enable 3 sfr (mirqenh, 0xdb). like the current and voltage channel waveform sampling modes, the waveform data is available at sample rates of 25.6 ksps, 12.8 ksps, 6.4 ksps, or 3.2 ksps. section). the voltage and current channels rms values are then multiplied together in the apparent power signal processing. because no additional offsets are created in the multiplication of the rms values, there is no specific offset compensation in the apparent power signal processing. the offset compensation of the apparent power measurement is done by calibrating each individual rms measurement. 06353-051 v rms i rms 0x1a36e2 apparent power signal (p) current rms signal ? i(t) voltage rms signal ? v(t) 0x00 0x1cf68c 0x00 0x1cf68c vagain to digital-to-frequency converter v armscfcon figure 75. apparent power signal processing
ADE7566/ade7569/ade7166/ade7169 rev. a | page 69 of 144 apparent energy calculation the apparent energy is given as the integral of the apparent power. = dt t power apparent energy apparent ) ( (33) the ADE7566/ade7569/ade7166/ade7169 achieve the integration of the apparent power signal by continuously accumulating the apparent power signal in an internal 48-bit register. the apparent energy register (vahr[23:0]) represents the upper 24 bits of this internal register. this discrete time accumulation or summation is equivalent to integration in continuous time. equation 34 expresses the relationship. ? ? ? ? ? ? = = 0 0 ) ( lim n t t nt power apparent energy apparent (34) where: n is the discrete time sample number. t is the sample period. the discrete time sample period (t) for the accumulation register in the ADE7566/ade7569/ade7166/ade7169 is 1.22 s (5/mclk). figure 76 shows this discrete time integration or accumulation. the apparent power signal is continuously added to the internal register. this addition is a signed addition even if the apparent energy theoretically remains positive. the 49 bits of the internal register are divided by vadiv. if the value in the vadiv register is 0, the internal apparent energy register is divided by 1. vadiv is an 8-bit unsigned register. the upper 24 bits are then written in the 24-bit apparent energy register (vahr[23:0]). the rvahr register (24 bits long) is provided to read the apparent energy. this register is reset to 0 after a read operation note that the apparent energy register is unsigned. by setting the vaehf and vaeof bits in the interrupt enable 2 sfr (mirqenm, 0xda), the ADE7566/ade7569/ade7166/ ade7169 can be configured to issue an ade interrupt to the 8052 core when the apparent energy register is half-full or when an overflow occurs. the half-full interrupt for the unsigned apparent energy register is based on 24 bits as opposed to 23 bits for the signed active energy register. integration times under stea dy load: apparent energy as mentioned in the apparent energy calculation section, the discrete time sample period (t) for the accumulation register is 1.22 s (5/mclk). with full-sca le sinusoidal signals on the analog inputs and the vagain register set to 0x000, the average word value from the apparent power stage is 0x1a36e2 (see the apparent power calculation section). the maximum value that can be stored in the apparent energy register before it overflows is 2 24 or 0xff,ffff. the average word value is added to the internal register, which can store 2 48 or 0xffff,ffff,ffff before it overflows. therefore, the integration time under these conditions with vadiv = 0 is calculated as follows: time = min 33 . 3 sec 199 s 22 . 1 0xd055 ffff ffff, 0xffff, = = (35) when vadiv is set to a value different from 0, the integration time varies, as shown in equation 36. time = time wdiv = 0 vadiv (36) 06353-052 vadiv apparent power or i rms + + v ahr[23:0] apparent power or i rms is accumulated (integrated) in the apparent energy register 23 0 48 0 48 0 % time (nt) t apparent power signal = p figure 76. apparent energy calculation
ADE7566/ade7569/ade7166/ade7169 rev. a | page 70 of 144 apparent energy pulse output all the ADE7566/ade7569/ade7166/ade7169 circuitry has a pulse output whose frequency is proportional to apparent power (see the energy-to-frequency conversion section). this pulse frequency output uses the calibrated signal after vagain. this output can also be used to output a pulse whose frequency is proportional to i rms . the pulse output is active low and should preferably be connected to an led, as shown in figure 79 . line apparent energy accumulation the ADE7566/ade7569/ade7166/ade7169 are designed with a special apparent energy accumulation mode that simplifies the calibration process. by using the on-chip, zero- crossing detection, the ADE7566/ade7569/ade7166/ ade7169 accumulate the apparent power signal in the lvahr register for an integral number of half cycles, as shown in figure 77 . the line apparent energy accumulation mode is always active. the number of half-line cycles is specified in the lincyc register, which is an unsigned 16-bit register. the ADE7566/ ade7569/ade7166/ade7169 can accumulate apparent power for up to 65,535 combined half cycles. because the apparent power is integrated on the same integral number of line cycles as the line active register and reactive energy register, these values can easily be compared. the energies are calculated more accurately because of this precise timing control and provide all the information needed for reactive power and power factor calculation. at the end of an energy calibration cycle, the cycend flag in the interrupt status 3 sfr (mirqsth, 0xde) is set. if the cycend enable bit in the interrupt enable 3 sfr (mirqenh, 0xdb) is enabled, the 8052 core has a pending ade interrupt. as for lwatthr, when a new half-line cycles is written in lincyc register, the lvahr register is reset and a new accumulation start at the next zero crossing. the number of half-line cycles is then counted until lincyc is reached. this implementation provides a valid measurement at the first cycend interrupt after writing to the lincyc register. the line apparent energy accumulation uses the same signal path as the apparent energy accumulation. the lsb size of these two registers is equivalent. apparent power no-load detection the ADE7566/ade7569/ade7166/ade7169 include a no- load threshold feature on the apparent power that eliminates any creep effects in the meter. the ADE7566/ade7569/ade7166/ ade7169 accomplish this by not accumulating energy if the multiplier output is below the no-load threshold. when the apparent power is below the no-load threshold, the vanoload flag in the interrupt status 1 sfr (mirqstl, 0xdc) is set. if the vanoload bit is set in the interrupt enable 1 sfr (mirqenl, 0xd9), the 8052 core has a pending ade interrupt. the ade interrupt stays active until the apnoload status bit is cleared (see the energy measurement interrupts section). the no-load threshold level is selectable by setting the vanoload bits in the nlmode register (0x0e). setting these bits to 0b00 disables the no-load detection and setting them to 0b01, 0b10, or 0b11 sets the no-load detection threshold to 0.030%, 0.015%, and 0.0075% of the full-scale output frequency of the multiplier, respectively. this no-load threshold can also be applied to the i rms pulse output when selected. in this case, the level of no-load threshold is the same as for the apparent energy. ampere-hour accumulation in a tampering situation where no voltage is available to the energy meter, the ADE7566/ade7569/ade7166/ade7169 is capable of accumulating the ampere-hour instead of apparent power into the vahr, rvahr, and lvahr. when bit 3 (varmscfcon) of the mode2 register (0x0c) is set, the vahr, rvahr, and lvahr, and the input for the digital-to-frequency converter accumulate i rms instead of apparent power. all the signal processing and calibration registers available for apparent power and energy accumulation remain the same when ampere- hour accumulation is selected. however, the scaling difference between i rms and apparent power requires independent values for gain calibration in the vagain, vadiv, cfxnum, and cfxden registers. 06353-053 lpf1 + + lvahr[23:0] lvahr register is updated every lincyc zero crossing with the total apparent energy during that duration from voltage channel adc 23 0 lincyc[15:0] 48 0 % zero-crossing detection calibr ation control vadiv[7:0] apparent power or i rms figure 77. line cycle apparent energy accumulation
ADE7566/ade7569/ade7166/ade7169 rev. a | page 71 of 144 pulse output configuration energy-to-freque ncy conversion the two pulse output circuits have separate configuration bits in the mode2 register (0x0c. setting the cfxsel bits to 0b00, 0b01, or 0b1x configures the dfc to create a pulse output proportional to active power, to reactive power (not available in the ADE7566 and ade7166), or to apparent power or i rms , respectively. the ADE7566/ade7569/ade7166/ade7169 also provide two energy-to-frequency conversions for calibration purposes. after initial calibration at manufacturing, the manufacturer or end customer often verify the energy meter calibration. one convenient way to do this is for the manufacturer to provide an output frequency that is proportional to the active power, reactive power, apparent power, or i rms under steady load conditions. this output frequency can provide a simple, single- wire, optically isolated interface to external calibration equipment. the selection between i rms and apparent power is done by the varmscfcon bit in the mode2 register (0x0c). with this selection, cf2 cannot be proportional to apparent power if cf1 is proportional to i rms , and cf1 cannot be proportional to apparent power if cf2 is proportional to i rms . figure 78 illustrates the energy-to-frequency conversion in the ADE7566/ade7569/ade7166/ade7169. var * va cfxsel[1:0] watt varmscfcon * available only in the ade7569 and ade7169 mode 2 register 0x0c i rms cfx pulse output cfxnum cfxden dfc 06353-054 pulse output characteristic the pulse output for both dfcs stays low for 90 ms if the pulse period is longer than 180 ms (5.56 hz). if the pulse period is shorter than 180 ms, the duty cycle of the pulse output is 50%. the pulse output is active low and should preferably be connected to an led, as shown in figure 79 . v dd cf 0 6353-055 figure 78. energy-to-frequency conversion figure 79. cf pulse output two digital-to-frequency converters (dfc) are used to generate the pulsed outputs. when wdiv = 0 or 1, the dfc generates a pulse each time 1 lsb in the energy register is accumulated. an output pulse is generated when cfxnum/cfxden number of pulses are generated at the dfc output. under steady load conditions, the output frequency is proportional to the active power, reactive power, apparent power, or i rms , depending on the cfxsel bits in the mode2 register (0x0c). the maximum output frequency with ac input signals at full scale and cfxnum = 0x00 and cfxden = 0x00 is approximately 21.1 khz. the ADE7566/ade7569/ade7166/ade7169 incorporate two registers per dfc, cfxnum[15:0] and cfxden[15:0], to set the cfx frequency. these are unsigned 16-bit registers that can be used to adjust the cfx frequency to a wide range of values. these frequency scaling registers are 16-bit registers that can scale the output frequency by 1/2 16 to 1 with a step of 1/2 16 . both pulse outputs can be enabled or disabled by clearing or setting bit discf1 and bit discf2 in the mode1 register (0x0b), respectively. if 0 is written to any of these registers, 1 is applied to the register. the ratio cfxnum/cfxden should be less than 1 to ensure proper operation. if the ratio of the cfxnum/cfxden registers is greater than 1, the register values are adjusted to a ratio of 1. for example, if the output frequency is 1.562 khz while the content of cfxden is 0 (0x000), the output frequency can be set to 6.1 hz by writing 0xff to the cfxden register. both pulse outputs set separate flags in the interrupt status 2 sfr (mirqstm, 0xdd), cf1 and cf2. if the cf1 and cf2 enable bits in the interrupt enable 2 sfr (mirqenm, 0xda) are set, the 8052 core has a pending ade interrupt. the ade interrupt stays active until the cf1 or cf2 status bits are cleared (see the energy measurement interrupts section).
ADE7566/ade7569/ade7166/ade7169 rev. a | page 72 of 144 energy register scaling the ADE7566/ade7569/ade7166/ade7169 provide measurements of active, reactive, and apparent energies that use separate paths and filtering for calculation. the difference in data paths can result in small differences in lsb weight between active, reactive, and apparent energy registers. these measurements are internally compensated so the scaling is nearly one to one. the relationship between these registers is shown in table 46 . table 46. energy registers scaling line frequency = 50 hz line frequency = 60 hz integrator var = 0.9952 watt var = 0.9949 watt off va = 0.9978 watt va = 1.0015 watt off var = 0.9997 watt var = 0.9999 watt on va = 0.9977 watt va = 1.0015 watt on energy measurement interrupts the energy measurement part of the ADE7566/ade7569/ ade7166/ade7169 has its own interrupt vector for the 8052 core, vector address 0x004b (see the interrupt vectors section). the bits set in the interrupt enable 1 sfr (mirqenl, 0xd9), interrupt enable 2 sfr (mirqenm, 0xda), and interrupt enable 3 sfr (mirqenh, 0xdb) enable the energy measurement interrupts that are allowed to interrupt the 8052 core. if an event is not enabled, it cannot create a system interrupt. the ade interrupt stays active until the status bit that has created the interrupt is cleared. the status bit is cleared when a zero is written to this register bit.
ADE7566/ade7569/ade7166/ade7169 rev. a | page 73 of 144 temperature, battery, and supply voltage measurements the ADE7566/ade7569/ade7166/ade7169 include temperature measurements as well as battery and supply voltage measurements. these measurements enable many forms of compensation. the temperature and supply voltage measurements can be used to compensate external circuitry. the rtc can be calibrated over temperature to ensure that it does not drift. supply voltage measurements allow the lcd contrast to be maintained despite variations in voltage. battery measurements allow low battery detection to be performed. all adc measurements are configured through the sfrs detailed in tabl e 47 . the temperature, battery, and supply voltage measurements can be configured to continue functioning in psm1 and psm2. keeping the temperature measurement active ensures that it is not necessary to wait for the temperature measurement to settle before using it for compensation. table 47. temperature, battery, and supply voltage measurement sfrs sfr address r/w name description 0xf9 r/w strbper peripheral adc strobe period (see table 48 ). 0xf3 r/w diffprog temperature and supply delta configuration (see table 49 ). 0xd8 r/w adcgo start adc measurement (see table 50 ). 0xfa r/w batvth battery detection threshold (see table 51 ). 0xef r/w vdcinadc v dcin adc value (see table 52 ). 0xdf r/w batadc battery adc value (see table 53 ). 0xd7 r/w tempadc temperature adc value (see table 54 ). table 48. peripheral adc strobe period sfr (strbper, 0xf9) 1 bit mnemonic default description 7 to 6 reserved 00 these bits should be left clear for proper operation. period for background external voltage measurements. vdcin_period[1:0] result 00 no v dcin measurement 01 8 min 10 2 min 5 to 4 vdcin_period[1:0] 0 11 1 min period for background battery level measurements. batt_period[1:0] result 00 no battery measurement 01 16 min 10 4 min 3 to 2 batt_period[1:0] 0 11 1 min period for background temperature measurements. temp_period[1:0] result 00 no temperature measurements 01 8 min 10 2 min 1 to 0 temp_period[1:0] 0 11 1 min 1 the strobing option only works when the rtcen bit in rtc configuration sf r (timecon, 0xa1) is set.
ADE7566/ade7569/ade7166/ade7169 rev. a | page 74 of 144 table 49. temperature and supply delta sfr (diffprog, 0xf3) bit mnemonic default description 7 to 6 reserved 0 reserved. difference threshold between last temperature measurement interrupting 8052 and new temperature measurement that should interrupt 8052. temp_diff[2:0] result 000 no interrupt 001 1 lsb ( 0.8c) 010 2 lsb ( 1.6c) 011 3 lsb ( 2.4c) 100 4 lsb ( 3.2c) 101 5 lsb ( 4c) 110 6 lsb ( 4.8c) 5 to 3 temp_diff[2:0] 0 111 every temperature measurement difference threshold between last external voltage measurement interrupting 8052 and new external measurement that should interrupt 8052. vdcin_diff[2:0] result 000 no interrupt 001 1 lsb ( 120 mv) 010 2 lsb ( 240 mv) 011 3 lsb ( 360 mv) 100 4 lsb ( 480 mv) 101 5 lsb ( 600 mv) 110 6 lsb ( 720 mv) 2 to 0 vdcin_diff[2:0] 0 111 every v dcin measurement table 50. start adc measurement sfr (adcgo, 0xd8) bit address mnemonic default description 7 0xdf pllack 0 set this bit to clear the pll fault bit, pll_ flt, in the periph register. a pll fault is generated if a reset is caused because the pll lost lock. 6 to 3 0xde to 0xdb reserved 0 reserved. 2 0xda vdcin_adc_g o 0 set this bit to initiate an external voltage measurement. this bit is cleared when the measurement request is received by the adc. 1 0xd9 temp_adc_go 0 set this bit to initiate a temperature me asurement. this bit is cleared when the measurement request is received by the adc. 0 0xd8 batt_adc_go 0 set this bit to initiate a battery meas urement. this bit is cleared when the measurement request is received by the adc. table 51. battery detection threshold sfr (batvth, 0xfa) bit mnemonic default description 7 to 0 batvth 0 the battery adc value is compared to this regist er, the battery threshold register. if batadc is lower than the threshold, an interrupt is generated. table 52. v dcin adc value sfr (vdcinadc, 0xef) bit mnemonic default description 7 to 0 vdcinadc 0 the v dcin adc value in this register is up dated when an adc interrupt occurs. table 53. battery adc value sfr (batadc, 0xdf) bit mnemonic default description 7 to 0 batadc 0 the battery adc value in this register is updated when an adc interrupt occurs. table 54. temperature adc value sfr (tempadc, 0xd7) bit mnemonic default description 7 to 0 tempadc 0 the temperature adc value in this register is updated when an adc interrupt occurs.
ADE7566/ade7569/ade7166/ade7169 rev. a | page 75 of 144 temperature measurement to provide a digital temperature measurement, each ADE7566/ade7569/ade7166/ade7169 includes a dedicated adc. an 8-bit temperature adc value sfr (tempadc, 0xd7) holds the results of the temperature conversion. the resolution of the temperature measurement is 0.78c/lsb. there are two ways to initiate a temperature conversion: a single temperature measurement or background temperature measurements. single temperature measurement set the temp_adc_go bit in the start adc measurement sfr (adcgo, 0xd8) to obtain a temperature measurement (see table 50 ). an interrupt is generated when the conversion is complete and when the temperature measurement is available in the temperature adc value sfr (tempadc, 0xd7). background temperature measurements background temperature measurements are disabled by default. to configure the background temperature measurement mode, set a temperature measurement interval in the peripheral adc strobe period sfr (strbper, 0xf9). temperature measurements are then performed periodically in the background (see tabl e 48 ). when a temperature conversion completes, the new temperature adc value is compared to the last temperature adc value that created an interrupt. if the absolute difference between the two values is greater than the setting in the temp_diff[2:0] bits in the temperature and supply delta sfr (diffprog, 0xf3), a tempadc interrupt is generated (see table 49 ). this allows temperature measurements to take place completely in the background, only requiring mcu activity if the temperature changes more than a configurable delta. to set up background temperature measurements, follow these steps: 1. initiate a single temperature measurement by setting the temp_adc_go bit in the start adc measurement sfr (adcgo, 0xd8). 2. upon completion of this measurement, configure the temp_diff[2:0] bits to establish the change in temperature that triggers an interrupt. 3. set up the interval for background temperature measurements by configuring the temp_period[1:0] bits in the peripheral adc strobe period sfr (strbper, 0xf9). temperature adc in psm0, psm1, and psm2 depending on the operating mode of the ADE7566/ade7569/ ade7166/ade7169, a temperature conversion is initiated only by certain actions. ? in psm0 operating mode, the 8052 is active. temperature measurements are available in the background measurement mode and by initiating a single measurement. ? in psm1 operating mode, the 8052 is active and the part is battery powered. single temperature measurements can be initiated by setting the temp_adc_go bit in the start adc measurement sfr (adcgo, 0xd8). background temperature measurements are not available. ? in psm2 operating mode, the 8052 is not active. temperature conversions are available through the background measurement mode only. the temperature adc value sfr (tempadc, 0xd7) is updated with a new value only when a temperature adc interrupt occurs. temperature adc interrupt the temperature adc can generate an adc interrupt when at least one of the following conditions occurs: ? the difference between the new temperature adc value and the last temperature adc value generating an adc interrupt is larger than the value set in the temp_diff[2:0] bits. ? the temperature adc conversion, initiated by setting start adc measurement sfr (adcgo, 0xd8) finishes. when the adc interrupt occurs, a new value is available in the temperature adc value sfr (tempadc, 0xd7). note that there is no flag associated with this interrupt. battery measurement to provide a digital battery measurement, each ADE7566/ ade7569/ade7166/ade7169 includes a dedicated adc. the battery measurement is available in an 8-bit sfr, the battery adc value sfr (batadc, 0xdf). the battery measurement has a resolution of 14.6 mv/lsb. a battery conversion can be initiated by two methods: a single battery measurement or background battery measurements. single battery measurement set the batt_adc_go bit in the start adc measurement sfr (adcgo, 0xd8) to obtain a battery measurement. an interrupt is generated when the conversion is done and when the battery measurement is available in the battery adc value sfr (batadc, 0xdf). background battery measurements to configure background measurements for the battery, establish a measurement interval in the peripheral adc strobe period sfr (strbper, 0xf9). battery measurements are then performed periodically in the background (see table 48 ). when a battery conversion completes, the battery adc value is compared to the low battery threshold, established in the battery detection threshold sfr (batvth, 0xfa). if the battery adc value is below this threshold, a low battery flag is set. this low battery flag is the fbat bit in the power management interrupt flag sfr (ipsmf, 0xf8), which is used for power supply moni- toring. this low battery flag can be enabled to generate the psm interrupt by setting the ebat bit in the power management interrupt enable sfr (ipsme, 0xec). this method allows battery measurements to take place completely in the background, only requiring mcu activity if the battery drops below a user- specified threshold.
ADE7566/ade7569/ade7166/ade7169 rev. a | page 76 of 144 to set up background battery measurements, follow these steps: 1. configure the battery detection threshold sfr (batvth, 0xfa) to establish a low battery threshold. if the batadc measurement is below this threshold, the fbat in the power management interrupt flag sfr (ipsmf, 0xf8) is set. 2. set up the interval for background battery measurements by configuring the batt_period[1:0] bits in the peripheral adc strobe period sfr (strbper, 0xf9). battery adc in psm0, psm1, and psm2 depending on the operating mode, a battery conversion is initiated only by certain actions. ? in psm0 operating mode, the 8052 is active. battery measurements are available in the background measurement mode and by initiating a single measurement. ? in psm1 operating mode, the 8052 is active and the part is battery powered. single battery measurements can be initiated by setting the batt_adc_go bit in the start adc measurement sfr (adcgo, 0xd8). background battery measurements are not available. ? in psm2 operating mode, the 8052 is not active. unlike temperature and vdcin measurements, the battery conversions are not available in this mode. battery adc interrupt the battery adc can generate an adc interrupt when at least one of the following conditions occurs: ? the new battery adc value is smaller than the value set in the battery detection threshold sfr (batvth, 0xfa), indicating a battery voltage loss. ? a single battery measurement initiated by setting the batt_adc_go bit finishes. when the battery flag (fbat) is set in the power management interrupt flag sfr (ipsmf, 0xf8), a new adc value is available in the battery adc value sfr (batadc, 0xdf). this battery flag can be enabled as a source of the psm interrupt to generate a psm interrupt every time the battery drops below a set voltage threshold or after a single conversion initiated by setting the batt_adc_go bit is ready. the battery adc value sfr (batadc, 0xdf) is updated with a new value only when the battery flag is set in the power management interrupt flag sfr (ipsmf, 0xf8). external voltage measurement the ADE7566/ade7569/ade7166/ade7169 include a dedicated adc to provide a digital measurement of an external voltage on the v dcin pin. an 8-bit sfr, the vdcin adc value sfr (vdcinadc, 0xef), holds the results of the conversion. the resolution of the external voltage measurement is 15.3 mv/lsb. there are two ways to initiate an external voltage conversion: a single external voltage measurement or background external voltage measurements. single external voltage measurement to obtain an external voltage measurement, set the vdcin_adc_go bit in the start adc measurement sfr (adcgo, 0xd8). an interrupt is generated when the conversion is done and when the external voltage measurement is available in the vdcin adc value sfr (vdcinadc, 0xef). background external voltage measurements background external voltage measurements are disabled by default. to configure the background external voltage measurement mode, set an ex ternal voltage measurement interval in the peripheral adc strobe period sfr (strbper, 0xf9). external voltage measurements are performed periodically in the background (see table 48 ). when an external voltage conversion is complete, the new external voltage adc value is compared to the last external voltage adc value that created an interrupt. if the absolute difference between the two values is greater than the setting in the vdcin_diff[2:0] bits in the temperature and supply delta sfr (diffprog, 0xf3), a v dcin adc flag is set. this v dcin adc flag is the fvdcin in the power management interrupt flag sfr (ipsmf, 0xf8), which is used for power supply monitoring. this v dcin adc flag can be enabled to generate a psm interrupt by setting the evdcin bit in the power management interrupt enable sfr (ipsme, 0xec). this method allows external voltage measurements to take place completely in the background, only requiring mcu activity if the external voltage has changed more than a configurable delta. to set up background external voltage measurements, follow these steps: 1. initiate a single external voltage measurement by setting the vdcin_adc_go bit in the start adc measurement sfr (adcgo, 0xd8). 2. upon completion of this measurement, configure the vdcin_diff[2:0] bits to establish the change in voltage that sets the fvdcin in the power management interrupt flag sfr (ipsmf, 0xf8). 3. set up the interval for background external voltage measurements by configuring the vdcin_period[1:0] bits in the peripheral adc strobe period sfr (strbper, 0xf9).
ADE7566/ade7569/ade7166/ade7169 rev. a | page 77 of 144 external voltage adc in psm1 and psm2 an external voltage conversion is initiated only by certain actions that depend on the operating mode of the ADE7566/ade7569/ ade7166/ade7169. ? in psm0 operating mode, the 8052 is active. external voltage measurements are available in the background measurement mode and by initiating a single measurement. ? in psm1 operating mode, the 8052 is active and the part is powered from battery. single external voltage measurements can be initiated by setting the vdcin_adc_go bit in the start adc measurement sfr (adcgo, 0xd8). background external voltage measurements are not available. ? in psm2 operating mode, the 8052 is not active. external voltage conversions are available through the background measurement mode only. the external voltage adc in the vdcin adc value sfr (vdcinadc, 0xef) is updated with a new value only when an external voltage adc interrupt occurs. external voltage adc interrupt the external voltage adc can generate an adc interrupt when at least one of the following conditions occurs: ? the difference between the new external voltage adc value and the last external voltage adc value generating an adc interrupt is larger than the value set in the vdcin_diff[2:0] bits in the temperature and supply delta sfr (diffprog, 0xf3). ? the external voltage adc conversion initiated by setting vdcin_adc_go finishes. when the adc interrupt occurs, a new value is available in the vdcin adc value sfr (vdcinadc, 0xef). note that there is no flag associated with this interrupt.
ADE7566/ade7569/ade7166/ade7169 rev. a | page 78 of 144 8052 mcu core architecture energy measurement pc 16kb electrically reprogrammable nonvolatile flash/ee program/data memory 8051 compatible core 256 bytes xram other on-chip peripherals: ? serial i/o ? wdt ? timers battery adc lcd driver temperature adc rtc power management 128-byte special function register area ir stack 256 bytes general purpose ram register banks 06353-056 the ADE7566/ade7569/ade7166/ade7169 have an 8052 mcu core and use the 8052 instruction set. some of the standard 8052 peripherals, such as the uart, have been enhanced. this section describes the standard 8052 core and its enhancements used in the ADE7566/ade7569/ade7166/ ade7169. the special function register (sfr) space is mapped into the upper 128 bytes of internal data memory space and is accessed by direct addressing only. it provides an interface between the cpu and all on-chip peripherals. a block diagram showing the programming model of the ADE7566/ade7569/ade7166/ ade7169 via the sfr area is shown in figure 80 . figure 80. ADE7566/ade7569/ade7166/ade7169 block diagram all registers except the program counter (pc), instruction register (ir), and the four general-purpose register banks reside in the sfr area. the sfr registers include power control, configuration, and data registers that provide an interface between the cpu and all on-chip peripherals. mcu registers the registers used by the mcu are summarized in this section. table 55. 8052 sfrs address mnemonic bit addressable description 0xe0 acc yes accumulator. 0xf0 b yes auxiliary math register. 0xd0 psw yes program status word (see table 56 ). 0x87 pcon no program control register (see table 57 ). 0x82 dpl no data pointer low (see table 58 ). 0x83 dph no data pointer high (see table 59 ). 0x83 and 0x82 dptr no data pointer (see table 60 ). 0x81 sp no stack pointer (see table 61 ). 0xaf cfg no configuration (see table 62 ). table 56. program status word sfr (psw, 0xd0) bit address mnemonic description 7 0xd7 cy carry flag. modified by add, addc, subb, mul, and div instructions. 6 0xd6 ac auxiliary carry flag. modified by add and addc instructions. 5 0xd5 f0 general-purpose flag available to the user. register bank select bits. 4 to 3 0xd4, 0xd3 rs1, rs0 rs1 rs0 result (selected bank) 0 0 0 0 1 1 1 0 2 1 1 3 2 0xd2 ov overflow flag. modified by add, addc, subb, mul, and div instructions. 1 0xd1 f1 general-purpose flag available to the user. 0 0xd0 p parity bit. the number of bits set in the accumulato r added to the value of the parity bit is always an even number.
ADE7566/ade7569/ade7166/ade7169 rev. a | page 79 of 144 table 57. program control sfr (pcon, 0x87) bit default description 7 0 smod bit. double baud rate control. 6 to 0 0 reserved. should be left cleared. table 58. data pointer low sfr (dpl, 0x82) bit default description 7 to 0 0 contain the low byte of the data pointer. table 59. data pointer high sfr (dph, 0x83) bit default description 7 to 0 0 contain the high byte of the data pointer. table 60. data pointer sfr (dptr, 0x82 and 0x83) bit default description 15 to 0 0 contain the 2-byte address of the data pointer. dptr is a combination of dph and dpl sfrs. table 61. stack pointer sfr (sp, 0x81) bit default description 7 to 0 7 contain the 8 lsbs of the pointer for the stack. table 62. configuration sfr (cfg, 0xaf) bit mnemonic description 7 reserved this bit should be left set for proper operation. enhanced uart enable bit. exten result 0 standard 8052 uart without enhanced error-checking features. 6 exten 1 enhanced uart with enhanced error checking (see the uart additional features section). synchronous communication selection bit. scps result 0 i 2 c port is selected for control of the shared i 2 c/spi pins and sfrs. 5 scps 1 spi port is selected for control of the shared i 2 c/spi pins and sfrs. 38 khz modulation enable bit. mod38en result 0 38 khz modulation is disabled. 4 mod38en 1 38 khz modulation is enabled on the pins selected by the mod38[7:0] bits in the extended port configuration sfr (epcfg, 0x9f). 3 to 2 reserved xrenx result xren1 or xren0 = 1 enables movx instruct ion to use 256 bytes of extended ram. 1 to 0 xren1, xren0 xren1 and xren0 = 0 disables movx instruction.
ADE7566/ade7569/ade7166/ade7169 rev. a | page 80 of 144 basic 8052 registers data pointer (dptr) program counter (pc) the data pointer is made up of two 8-bit registers: dph (high byte) and dpl (low byte). these provide memory addresses for internal code and data access. the dptr can be manipulated as a 16-bit register (dptr = dph, dpl) or as two independent 8-bit registers (dph, dpl). see the program counter holds the two byte address of the next instruction to be fetched. the pc is initialized with 0x00 at reset and is incremented after each instruction is performed. note that the amount added to the pc depends on the number of bytes in the instruction, so the increment can range from one byte to three bytes. the program counter is not directly accessible to the user but can be directly modified by call and jmp instructions that change which part of the program is active. table 58 and table 59 . the ADE7566/ade7569/ade7166/ade7169 support dual data pointers. see the dual data pointers section. note that the dual data pointers section of the data sheet is the only place where the main and shadow data pointers are distinguished. whenever the data pointer (dptr) is mentioned elsewhere in the data sheet, active dptr is implied. instruction register (ir) the instruction register holds the operations code of the instruction being executed. the operations code is the binary code that results from assembling an instruction. this register is not directly accessible to the user. stack pointer (sp) the stack pointer keeps track of the current address at the top of the stack. to push a byte of data onto the stack, the stack pointer is incremented and the data is moved to the new top of the stack. to pop a byte of data off the stack, the top byte of data is moved into the awaiting address, and the stack pointer is decremented. the stack is a last in, first out (lifo) method of data storage because the most recent addition to the stack is the first to come off it. register banks there are four banks that each contain eight byte-wide registers for a total of 32 bytes of registers. these registers are convenient for temporary storage of mathematical operands. an instruction involving the accumulator and a register can be executed in one clock cycle, as opposed to two clock cycles to perform an instruction involving the accumulator and a literal or a byte of general-purpose ram. the register banks are located in the first 32 bytes of ram. the stack is utilized during call and ret instructions to keep track of the address to move into the pc when returning from the function call. the stack is also manipulated when vectoring for interrupts to keep track of the prior state of the pc. the active register bank is selected by the rs0 and rs1 bits in the program status word sfr (psw, 0xd0). the stack resides in the internal extended ram, and the sp register holds the address of the stack in the extended ram (xram). the advantage of this solution is that the stack is segregated to the internal xram. the use of the general- purpose ram can be limited to data storage, and the use of the extended internal ram can be limited to the stack pointer. this separation limits the chance of data ram corruption when the stack pointer overflows in data ram. accumulator the accumulator is a working register, storing the results of many arithmetic or logical operations. the accumulator is used in more than half of the 8052 instructions where it is usually referred to as a. the program status register (psw) constantly monitors the number of bits that are set in the accumulator to determine if it has even or odd parity. the accumulator is stored in the sfr space (see tabl e 55 ). data can still be stored in xram by using the movx command. b register 0x00 0xff 0xff 0x00 256 bytes of on-chip xram data + stack 256 bytes of ram (data) 0 6353-057 the b register is used by the multiply and divide instructions, mul ab and div ab to hold one of the operands. because the b register is not used for many instructions, it can be used as a scratch pad register such as those in the register banks. the b register is stored in the sfr space (see table 55 ). program status word (psw) figure 81. extended stack pointer operation the psw register reflects the status of arithmetic and logical operations through carry, auxiliary carry, and overflow flags. the parity flag reflects the parity of the accumulator contents, which can be helpful for communication protocols. the psw bits are described in to change the default starting address for the stack, move a value into the stack pointer (sp). for example, to enable the extended stack pointer and initialize it at the beginning of the xram space, use the following code: table 56 . the program status word sfr (psw, 0xd0) is bit addressable. mov sp,#00h
ADE7566/ade7569/ade7166/ade7169 rev. a | page 81 of 144 program control register (pcon, 0x87) standard 8052 sfrs the 8052 core defines two power-down modes: power down and idle. the ADE7566/ade7569/ade7166/ade7169 enhance the power control capability of the traditional 8052 mcu with additional power management functions. the power control sfr (powcon, 0xc5) is used to define power control-specific functionality for the ADE7566/ade7569/ ade7166/ade7169. the program control sfr (pcon, 0x87) is not bit addressable. see the the standard 8052 special function registers include the accumulator, b, psw, dptr, and sp sfrs described in the basic 8052 registers section. the standard 8052 sfrs also define timers, the serial port interface, interrupts, i/o ports, and power-down modes. timer sfrs the 8052 contains three 16-bit timers: the identical timer0 and timer1, as well as a timer2. these timers can also function as event counters. timer2 has a capture feature where the value of the timer can be captured in two 8-bit registers upon the assertion of an external input signal (see power management section. the ADE7566/ade7569/ade7166/ade7169 have many other peripherals not standard to the 8052 core, including ? ade energy measurement dsp table 102 and the timers section). ? rtc ? lcd driver serial port sfrs ? battery switchover/power management the full-duplex serial port peripheral requires two registers, one for setting up the baud rate and other communication parameters, and another for the transmit/receive buffer. the ADE7566/ade7569/ade7166/ade7169 also have enhanced serial port functionality with a dedicated timer for baud rate generation with a fractional divisor and additional error detection. see ? temperature adc ? battery adc ? spi/i 2 c communication ? flash memory controller ? watchdog timer table 131 and the uart serial interface section. memory overview interrupt sfrs the ADE7566/ade7569/ade7166/ade7169 contain the following memory blocks: there is a two-tiered interrupt system standard in the 8052 core. the priority level for each interrupt source is individually selectable as high or low. the ADE7566/ade7569/ade7166/ ade7169 enhance this interrupt system by creating, in essence, a third interrupt tier for a highest priority, the power supply management interrupt (psm). see the ? 16 kb of on-chip flash/ee program and data memory ? 256 bytes of general-purpose ram ? 256 bytes of internal extended ram (xram) interrupt system section. the 256 bytes of general-purpose ram share the upper 128 bytes of its address space with special function registers. all of the memory spaces are shown in i/o port sfrs figure 80 . the addressing mode specifies which memory space to access. the 8052 core supports four i/o ports, port 0 through port 3, where port 0 and port 2 are typically used to access external code and data spaces. the ADE7566/ade7569/ade7166/ ade7169, unlike standard 8052 products, provide internal nonvolatile flash memory so that an external code space is unnecessary. the on-chip lcd driver requires many pins, some of which are dedicated for lcd functionality, and others that can be configured as lcd or general-purpose inputs/outputs. due to the limited number of i/o pins, the ADE7566/ade7569/ ade7166/ade7169 do not allow access to external code and data spaces. general-purpose ram general-purpose ram resides in the 0x00 through 0xff memory locations. it contains the register banks. 11 10 01 00 reset value of stack pointer four banks of eight registers r0 to r7 bit-addressable (bit addresses) general-purpose area banks selected via bits in psw 0x 00 0x08 0x10 0x18 0x20 0x30 0x07 0x0f 0x17 0x1f 0x2f 0x7f 0 6353-058 the ADE7566/ade7569/ade7166/ade7169 provide 20 pins that can be used for general-purpose i/o. these pins are mapped to port 0, port 1, and port 2. they are accessed through three bit- addressable 8052 sfrs, p0, p1, and p2. another enhanced feature of the ADE7566/ade7569/ade7166/ade7169 is that the weak pull-ups standard on 8052 port 1, port 2, and port 3 can be disabled to make open drain outputs, as is standard on port 0. the weak pull-ups can be enabled on a pin-by-pin basis. see the i/o ports section. figure 82. lower 128 bytes of internal data memory
ADE7566/ade7569/ade7166/ade7169 rev. a | page 82 of 144 address 0x80 through address 0xff of general-purpose ram are shared with the special function registers. the mode of addressing determines which memory space is accessed, as shown in figure 83 . general-purpose ram special function registers (sfrs) accessible by indirect addressing only accessible by direct and indirect addressing accessible by direct addressing only 0xff 0x80 0x7f 0x00 06353-059 figure 83. general-purpose ram and sfr memory address overlap both direct and indirect addressing can be used to access general- purpose ram from 0x00 through 0x7f. however, only indirect addressing can be used to access general-purpose ram from 0x80 through 0xff because this address space shares the same space with the special function registers (sfrs). the 8052 core also has the means to access individual bits of certain addresses in the general-purpose ram and special function memory spaces. the individual bits of general-purpose ram address 0x20 to address 0x2f can be accessed through their bit address 0x00 through bit address 0x7f. the benefit of bit addressing is that the individual bits can be accessed quickly without the need for bit masking, which takes more code memory and execution time. the bit addresses for general-purpose ram address 0x20 through address 0x2f can be seen in figure 84 . byte a ddress bit addresses (hexa) 0x2f 0x2e 0x2d 0x2c 0x2b 0x2a 0x29 0x28 0x27 0x26 0x25 0x24 0x23 0x22 0x21 0x20 7f 77 6f 67 5f 57 4f 47 3f 37 2f 27 1f 17 0f 07 7e 76 6e 66 5e 56 4e 46 3e 36 2e 26 1e 16 0e 06 7d 75 6d 65 5d 55 4d 45 3d 35 2d 25 1d 15 0d 05 7c 74 6c 64 5c 54 4c 44 3c 34 2c 24 1c 14 0c 04 7b 73 6b 63 5b 53 4b 43 3b 33 2b 23 1b 13 0b 03 7a 72 6a 62 5a 52 4a 42 3a 32 2a 22 1a 12 0a 02 79 71 69 61 59 51 49 41 39 31 29 21 19 11 09 01 78 70 68 60 58 50 48 40 38 30 28 20 18 10 08 00 06353-060 figure 84. bit addressable area of general-purpose ram bit addressing can be used for instructions that involve boolean variable manipulation and program branching (see the instruction set section). special function registers special function registers are registers that affect the function of the 8052 core or its peripherals. these registers are located in ram in address 0x80 through address 0xff. they are only accessible through direct addressing as shown in figure 83 . the individual bits of some sfrs can be accessed for use in boolean and program branching instructions. these sfrs are labeled as bit-addressable and the bit addresses are given in the sfr mapping section. extended internal ram (xram) the ADE7566/ade7569/ade7166/ade7169 provide 256 bytes of extended on-chip ram. no external ram is supported. this ram is located in address 0x0000 through address 0x00ff in the extended ram space. to select the extended ram memory space, the extended indirect addressing modes are used. the internal xram is enabled in the configuration sfr (cfg, 0xaf) by writing 01 to cfg[1:0]. 256 bytes of extended internal ram (xram) 0x00f f 0x0000 06353-061 figure 85. extended internal ram (xram) space code memory code and data memory are stored in the 16 kb flash memory space. no external code memory is supported. to access code memory, code indirect addressing is used. addressing modes the 8052 core provides several addressing modes. the addressing mode determines how the core interprets the memory location or data value specified in assembly language code. there are six addressing modes as shown in table 63 . table 63. 8052 addressing modes core clock cycles addressing mode example bytes immediate mov a,#a8h 2 2 mov dptr,#a8h 3 3 direct mov a,a8h 2 2 mov a,ie 2 2 mov a,r0 1 1 indirect mov a,@r0 1 2 extended direct movx a,@dptr 1 4 extended indirect movx a,@r0 1 4 code indirect movc a,@a+dptr 1 4 movc a,@a+pc 1 4 jmp @a+dptr 1 3 immediate addressing in immediate addressing, the expression entered after the number sign (#) is evaluated by the assembler and stored in the specified memory address. this number is referred to as a literal because it refers only to a value and not to a memory location. instructions using this addressing mode are slower than those between two registers because the literal must be stored and fetched from memory. the expression can be entered as a symbolic variable or an arithmetic expression; the value is computed by the assembler.
ADE7566/ade7569/ade7166/ade7169 rev. a | page 83 of 144 direct addressing with direct addressing, the value at the source address is moved to the destination address. direct addressing provides the fastest execution time of all the addressing modes when an instruction is performed between registers. note that indirect or direct addressing modes can be used to access general-purpose ram address 0x00 through address 0x7f. an instruction with direct addressing that uses an address between 0x80 and 0xff is referring to a special function memory location. indirect addressing with indirect addressing, the value pointed to by the register is moved to the destination address. for example, to move the contents of internal ram address 0x82 to the accumulator, use the following instructions: mov r0,#82h mov a,@r0 these two instructions require a total of four clock cycles and three bytes of storage in the program memory. indirect addressing allows addresses to be computed, which is useful for indexing into data arrays stored in ram. note that an instruction that refers to address 0x00 through address 0x7f is referring to internal ram, and indirect or direct addressing modes can be used. an instruction with indirect addressing that uses an address between 0x80 and 0xff is referring to internal ram, not to an sfr. extended direct addressing the dptr register (see table 60 ) is used to access internal extended ram in extended indirect addressing mode. the ADE7566/ade7569/ade7166/ade7169 have 256 bytes of xram, accessed through movx instructions. external memory spaces are not supported on this device. in extended direct addressing mode, the dptr register points to the address of the byte of extended ram. the following code moves the contents of extended ram address 0x100 to the accumulator: mov dptr,#100h movx a,@dptr these two instructions require a total of seven clock cycles and four bytes of storage in the program memory. extended indirect addressing the internal extended ram is accessed through a pointer to the address in indirect addressi ng mode. the ADE7566/ade7569/ ade7166/ade7169 have 256 bytes of internal extended ram, accessed through movx instructions. external memory is not supported on the devices. in extended indirect addressing mode, a register holds the address of the byte of extended ram. the following code moves the contents of extended ram address 0x80 to the accumulator: mov r0,#80h movx a,@r0 these two instructions require six clock cycles and three bytes of storage. note that there are 256 bytes of extended ram; therefore, both extended direct and extended indirect addressing can cover the whole address range. there is a storage and speed advantage to using extended indirect addressing because the additional byte of addressing available through the dptr register that is not needed is not stored. from the three examples demonstrating the access of internal ram from 0x80 through 0xff, and the access of extended internal ram from 0x00 through 0xff, it can be seen that it is most efficient to use the entire internal ram accessible through indirect access before moving to extended ram. code indirect addressing the internal code memory can be accessed indirectly. this can be useful for implementing lookup tables and other arrays of constants that are stored in flash. for example, to move the data stored in flash memory at address 0x8002 into the accumulator, use the following code: mov dptr,#8002h clr a movx a,@a+dptr the accumulator can be used as a variable index into the array of flash memory located at dptr.
ADE7566/ade7569/ade7166/ade7169 rev. a | page 84 of 144 instruction set table 64 documents the number of clock cycles required for each instruction. most instructions are executed in one or two clock cycles, resulting in a 4-mips peak performance. table 64. instruction set mnemonic description bytes cycles arithmetic add a,rn add register to a. 1 1 add a,@ri add indirect memory to a. 1 2 add a,dir add direct byte to a. 2 2 add a,#data add immediate to a. 2 2 addc a,rn 1 1 add register to a with carry. 1 1 addc a,@ri add indirect memory to a with carry. 1 2 addc a,dir add direct byte to a with carry. 2 2 add a,#data add immediate to a with carry. 2 2 subb a,rn subtract register from a with borrow. 1 1 subb a,@ri subtract indirect memory from a with borrow. 1 2 subb a,dir subtract direct from a with borrow. 2 2 subb a,#data subtract immediate from a with borrow. 2 2 inc a increment a. 1 1 inc rn increment register. 1 1 inc @ ri increment indirect memory. 1 2 inc dir increment direct byte. 2 2 inc dptr increment data pointer. 1 3 dec a decrement a. 1 1 dec rn decrement register. 1 1 dec @ri decrement indirect memory. 1 2 dec dir decrement direct byte. 2 2 mul ab multiply a by b. 1 9 div ab divide a by b. 1 9 da a a decimal adjust a. 1 2 logic anl a,rn and register to a. 1 1 anl a,@ri and indirect memory to a. 1 2 anl a,dir and direct byte to a. 2 2 anl a,#data and immediate to a. 2 2 anl dir,a and a to direct byte. 2 2 anl dir,#data and immediate data to direct byte. 3 3 orl a,rn or register to a. 1 1 orl a,@ri or indirect memory to a. 1 2 orl a,dir or direct byte to a. 2 2 orl a,#data or immediate to a. 2 2 orl dir,a or a to direct byte. 2 2 orl dir,#data or immediate data to direct byte. 3 3 xrl a,rn exclusive-or register to a. 1 1 xrl a,@ri exclusive-or indirect memory to a. 2 2 xrl a,#data exclusive-or immediate to a. 2 2 xrl dir,a exclusive-or a to direct byte. 2 2 xrl a,dir exclusive-or indirect memory to a. 2 2 xrl dir,#data exclusive-or immediate data to direct. 3 3 clr a clear a. 1 1 cpl a complement a. 1 1 swap a swap nibbles of a. 1 1 rl a rotate a left. 1 1
ADE7566/ade7569/ade7166/ade7169 rev. a | page 85 of 144 mnemonic description bytes cycles rlc a rotate a left through carry. 1 1 rr a rotate a right. 1 1 rrc a rotate a right through carry. 1 1 data transfer mov a,rn move register to a. 1 1 mov a,@ri move indirect memory to a. 1 2 mov rn,a move a to register. 1 1 mov @ri,a move a to indirect memory. 1 2 mov a,dir move direct byte to a. 2 2 mov a,#data move immediate to a. 2 2 mov rn,#data move register to immediate. 2 2 mov dir,a move a to direct byte. 2 2 mov rn,dir move register to direct byte. 2 2 mov dir,rn move direct to register. 2 2 mov @ri,#data move immediate to indirect memory. 2 2 mov dir,@ri move indirect to direct memory. 2 2 mov @ri,dir move direct to indirect memory. 2 2 mov dir,dir move direct byte to direct byte. 3 3 mov dir,#data move immediate to direct byte. 3 3 mov dptr,#data move immediate to data pointer. 3 3 movc a,@a+dptr move code byte relative dptr to a. 1 4 movc a,@a+pc move code byte relative pc to a 1. 1 4 movx a,@ri move external (a8) data to a. 1 4 movx a,@dptr move external (a16) data to a. 1 4 movx @ri,a move a to external data (a8). 1 4 movx @dptr,a move a to external data (a16). 1 4 push dir push direct byte onto stack. 2 2 pop dir pop direct byte from stack. 2 2 xch a,rn exchange a and register. 1 1 xch a,@ri exchange a and indirect memory. 1 2 xchd a,@ri exchange a and indirect memory nibble. 1 2 xch a,dir exchange a and direct byte. 2 2 boolean clr c clear carry. 1 1 clr bit clear direct bit. 2 2 setb c set carry. 1 1 setb bit set direct bit. 2 2 cpl c complement carry. 1 1 cpl bit complement direct bit. 2 2 anl c,bit and direct bit and carry. 2 2 anl c,/bit and direct bit inverse to carry. 2 2 orl c,bit or direct bit and carry. 2 2 orl c,/bit or direct bit inverse to carry. 2 2 mov c,bit move direct bit to carry. 2 2 mov bit,c move carry to direct bit. 2 2 branching jmp @a+dptr jump indirect relative to dptr. 1 3 ret return from subroutine. 1 4 reti return from interrupt. 1 4 acall addr11 absolute jump to subroutine. 2 3 ajmp addr11 absolute jump unconditional. 2 3 sjmp rel short jump (relative address). 2 3 jc rel jump on carry equal to 1. 2 3
ADE7566/ade7569/ade7166/ade7169 rev. a | page 86 of 144 mnemonic description bytes cycles jnc rel jump on carry equal to 0. 2 3 jz rel jump on accumulator = 0. 2 3 jnz rel jump on accumulator not equal to 0. 2 3 djnz rn,rel decrement register, jnz relative. 2 3 ljmp long jump unconditional. 3 4 lcall addr16 long jump to subroutine. 3 4 jb bit,rel jump on direct bit = 1. 3 4 jnb bit,rel jump on direct bit = 0. 3 4 jbc bit,rel jump on direct bit = 1 and clear. 3 4 cjne a,dir,rel compare a, direct jne relative. 3 4 cjne a,#data,rel compare a, immediate jne relative. 3 4 cjne rn,#data,rel compare register, immediate jne relative. 3 4 cjne @ri,#data,rel compare indirect, immediate jne relative. 3 4 djnz dir,rel decrement direct byte, jnz relative. 3 4 miscellaneous nop no operation. 1 1 read-modify-write instructions some 8052 instructions read the latch and others read the pin. the state of the pin is read for instructions that input a port bit. instructions that read the latch rather than the pins are the ones that read a value, possibly change it, and rewrite it to the latch. because these instructions involve modifying the port, it is assumed that the pins being modified are outputs, so the output state of the pin is read from the latch. this prevents a possible misinterpretation of the voltage level of a pin. for example, if a port pin is used to drive the base of a transistor, a 1 is written to the bit to turn on the transistor. if the cpu reads the same port bit at the pin rather than the latch, it reads the base voltage of the transistor and interprets it as logic 0. reading the latch rather than the pin returns the correct value of 1. the instructions that read the latch rather than the pins are called read-modify-write instructions and are listed in table 65 . when the destination operand is a port or a port bit, these instructions read the latch rather than the pin. table 65. read-modify-write instructions instruction example description anl anl p0,a logical and. orl orl p1,a logical or. xrl xrl p2,a logical ex-or. jbc jbc p1.1,label jump if bit = 1 and clear bit. cpl cpl p2.0 complement bit. inc inc p2 increment. dec dec p2 decrement. djnz djnz p0,label decrement and jump if not zero. mov px.y,c 1 mov p0.0,c move carry to bit y of port x. clr px.y 1 clr p0.0 clear bit y of port x. setb px.y 1 setb p0.0 set bit y of port x. 1 these instructions read the port byte (all 8 bits), modify the addressed bit, and write the new byte back to the latch. instructions that affect flags many instructions explicitly modify the carry bit, such as the mov c bit and clr c instructions. other instructions that affect status flags are listed in this section. add a, source this instruction adds the source to the accumulator. no status flags are referenced by the instruction. affected status flags c set if there is a carry out of bit 7. cleared otherwise. used to indicate an overflow if the operands are unsigned. ov set if there is a carry out of bit 6 or a carry out of bit 7, but not if both are set. used to indicate an overflow for signed addition. this flag is set if two positive operands yield a negative result or if two negative operands yield a positive result. ac set if there is a carry out of bit 3. cleared otherwise. addc a, source this instruction adds the source and the carry bit to the accu- mulator. the carry status flag is referenced by the instruction. affected status flags c set if there is a carry out of bit 7. cleared otherwise. used to indicate an overflow if the operands are unsigned. ov set if there is a carry out of bit 6 or a carry out of bit 7, but not if both are set. used to indicate an overflow for signed addition. this flag is set if two positive operands yield a negative result or if two negative operands yield a positive result. ac set if there is a carry out of bit 3. cleared otherwise.
ADE7566/ade7569/ade7166/ade7169 rev. a | page 87 of 144 subb a, source this instruction subtracts the source byte and the carry (borrow) flag from the accumulator. it references the carry (borrow) status flag. affected status flags c set if there is a borrow needed for bit 7. cleared otherwise. used to indicate an overflow if the operands are unsigned. ov set if there is a borrow needed for bit 6 or bit 7, but not for both. used to indicate an overflow for signed subtraction. this flag is set if a negative number subtracted from a positive yields a negative result or if a positive number subtracted from a negative number yields a positive result. ac set if a borrow is needed for bit 3. cleared otherwise. mul ab this instruction multiplies the accumulator by the b register. this operation is unsigned. the lower byte of the 16-bit product is stored in the accumulator and the higher byte is left in the b register. no status flags are referenced by the instruction. affected status flags c cleared ov set if the result is greater than 255. cleared otherwise. div ab this instruction divides the accumulator by the b register. this operation is unsigned. the integer part of the quotient is stored in the accumulator and the remainder goes into the b register. no status flags are referenced by the instruction. affected status flags c cleared ov cleared unless the b register is equal to 0, in which case the results of the division are undefined and the ov flag is set. da a this instruction adjusts the accumulator to hold two 4-bit digits after the addition of two binary coded decimals (bcds) with the add or addc instructions. if the ac bit is set or if the value of bit 0 to bit 3 exceeds nine, 0x06 is added to the accumulator to correct the lower four bits. if the carry bit is set when the instruction begins, or if 0x06 is added to the accumulator in the first step, 0x60 is added to the accumulator to correct the higher four bits. the carry and ac status flags are referenced by this instruction. affected status flag c set if the result is greater than 0x99. cleared otherwise. rrc a this instruction rotates the accumulator to the right through the carry flag. the old lsb of the accumulator becomes the new carry flag, and the old carry flag is loaded into the new msb of the accumulator. the carry status flag is referenced by this instruction. affected status flag c equal to the state of acc.0 before execution of the instruction. rlc a this instruction rotates the accumulator to the left through the carry flag. the old msb of the accumulator becomes the new carry flag, and the old carry flag is loaded into the new lsb of the accumulator. the carry status flag is referenced by this instruction. affected status flag c equal to the state of acc.7 before execution of the instruction. cjne destination, source, relative jump this instruction compares the source value to the destination value and branches to the location set by the relative jump if they are not equal. if the values are equal, program execution continues with the instruction after the cjne instruction. no status flags are referenced by this instruction. affected status flag c set if the source value is greater than the destination value. cleared otherwise.
ADE7566/ade7569/ade7166/ade7169 rev. a | page 88 of 144 dual data pointers each ADE7566/ade7569/ade7166/ade7169 incorporates two data pointers. the second data pointer is a shadow data pointer and is selected via the data pointer control sfr (dpcon, 0xa7). dpcon features automatic hardware postincrement and postdecrement, as well as an automatic data pointer toggle. note that this section of the data sheet is the only place where the main and shadow data pointers are distinguished. whenever the data pointer (dptr) is mentioned elsewhere in the data sheet, active dptr is implied. in addition, only the movc/movx @dptr instructions automatically postincrement and postdecrement the dptr. other movc/movx instructions, such as movc pc or movc @ri, do not cause the dptr to automatically postincrement and postdecrement. to illustrate the operation of dpcon, the following code copies 256 bytes of code memory at address 0xd000 into xram, starting from address 0x0000: mov dptr,#0 ;main dptr = 0 mov dpcon,#55h ;select shadow dptr ;dptr1 increment mode ;dptr0 increment mode ;dptr auto toggling on mov dptr,#0d000h ;dptr = d000h moveloop: clr a movc a,@a+dptr ;get data ;post inc dptr ;swap to main dptr(data) movx @dptr,a ;put acc in xram ;increment main dptr ;swap shadow dptr(code) mov a, dpl jnz moveloop table 66. data pointer control sfr (dpcon, 0xa7) bit mnemonic default description 7 0 not implemented. write dont care. 6 dpt 0 data pointer automatic toggle enable. cleared by th e user to disable autoswapping of the dptr. set in user software to enable automatic toggling of the dptr after each movx or movc instruction. dp1m1, dp1m0 0 shadow data pointer mode. these bits enable extra modes of the shadow data pointer operation, allowing more compact and more efficient code size and execution. dp1m1 dp1m0 result (behavior of the shadow data pointer) 0 0 8052 behavior. 0 1 dptr is postincremented afte r a movx or a movc instruction. 1 0 dptr is postdecremented af ter a movx or movc instruction. 5, 4 1 1 dptr lsb is toggled after a movx or movc instruction. this instruction can be useful for moving 8-bit blocks to/from 16-bit devices. dp0m1, dp0m0 0 main data pointer mode. these bits enable extra modes of the main data pointer operation, allowing more compact and more effici ent code size and execution. dp0m1 dp0m0 result (behavior of the main data pointer) 0 0 8052 behavior. 0 1 dptr is postincremented afte r a movx or a movc instruction. 1 0 dptr is postdecremented af ter a movx or movc instruction. 3, 2 1 1 dptr lsb is toggled after a movx or movc instruction. this instruction is useful for moving 8-bit blocks to/from 16-bit devices. 1 0 not implemented. write dont care. 0 dpsel 0 data pointer select. cleared by the user to select th e main data pointer, meaning that the contents of this 16-bit register are placed into the dpl sfr and d ph sfr. set by the user to select the shadow data pointer, meaning that the contents of a separate 16- bit register appear in the dpl srf and dph sfr.
ADE7566/ade7569/ade7166/ade7169 rev. a | page 89 of 144 interrupt system the unique power management architecture of the ADE7566/ ade7569/ade7166/ade7169 includes an operating mode (psm2) where the 8052 mcu core is shut down. events can be configured to wake the 8052 mcu core from the psm2 operating mode. a distinction is drawn here between events that can trigger the wake-up of the 8052 mcu core and events that can trigger an interrupt when the mcu core is active. events that can wake the core are referred to as wake-up events, whereas events that can interrupt the program flow when the mcu is active are called interrupts. see the 3.3 v peripherals and wake-up events section to learn more about events that can wake the 8052 core from psm2. the ADE7566/ade7569/ade7166/ade7169 provide 12 interrupt sources with three priority levels. the power management interrupt is at the highest priority level. the other two priority levels are configurable through the interrupt priority sfr (ip, 0xb8) and interrupt enable and priority 2 sfr (ieip2, 0xa9). standard 8052 interrupt architecture the 8052 standard interrupt architecture includes two tiers of interrupts, where some interrupts are assigned a high priority and others are assigned a low priority. priority 1 priority 0 high low 06353-062 figure 86. standard 8052 interrupt priority levels a priority 1 interrupt can interrupt the service routine of a priority 0 interrupt, and if two interrupts of different priorities occur at the same time, the priority 1 interrupt is serviced first. an interrupt cannot be interrupted by another interrupt of the same priority level. if two interrupts of the same priority level occur simultaneously, a polling sequence is observed. see the interrupt priority section. interrupt architecture the ADE7566/ade7569/ade7166/ade7169 possess advanced power supply monitoring features. to ensure a fast response to time-critical power supply issues, such as a loss of line power, the power supply monitoring interrupt should be able to interrupt any interrupt service routine. to enable the user to have full use of the standard 8052 interrupt priority levels, an additional priority level is added for the power supply management (psm) interrupt. the psm interrupt is the only interrupt at this highest interrupt priority level. priority 1 priority 0 psm high low 0 6353-063 figure 87. interrupt architecture see the power supply monitor interrupt (psm) section for more information on the psm interrupt. interrupt registers the control and configuration of the interrupt system is carried out through four interrupt-related sfrs discussed in this section. table 67. interrupt sfrs sfr address default bit addressable description ie 0xa8 0x00 yes interrupt enable (see table 68 ). ip 0xb8 0x00 yes interrupt priority (see table 69 ). ieip2 0xa9 0xa0 no interrup t enable and priority 2 (see table 70 ). wdcon 0xc0 0x10 yes table 75 and the watchdog timer (see writing to the watchdog timer sfr (wdcon, 0xc0) section). table 68. interrupt enable sfr (ie, 0xa8) bit address mnemonic description 7 0xaf ea enables all interrupt sources. set by the user. cleared by the user to disa ble all interrupt sources. 6 0xae etemp enables the temperature adc interrupt. set by the user. 5 0xad et2 enables the timer 2 interrupt. set by the user. 4 0xac es enables the uart serial port interrupt. set by the user. 3 0xab et1 enables the timer 1 interrupt. set by the user. 2 0xaa ex1 enables the external interrupt 1 ( int1 ). set by the user. 1 0xa9 et0 enables the timer 0 interrupt. set by the user. 0 0xa8 ex0 enables external interrupt 0 ( int0 ). set by the user.
ADE7566/ade7569/ade7166/ade7169 rev. a | page 90 of 144 table 69. interrupt priority sfr (ip, 0xb8) bit address mnemonic description 7 0xbf pade ade energy measurement interrupt priority (1 = high, 0 = low). 6 0xbe ptemp temperature adc interrupt priority (1 = high, 0 = low). 5 0xbd pt2 timer 2 interrupt priority (1 = high, 0 = low). 4 0xbc ps uart serial port interrupt priority (1 = high, 0 = low). 3 0xbb pt1 timer 1 interrupt priority (1 = high, 0 = low). 2 0xba px1 int1 (external interrupt 1) priority (1 = high, 0 = low). 1 0xb9 pt0 timer 0 interrupt priority (1 = high, 0 = low). 0 0xb8 px0 int0 (external interrupt 0) priority (1 = high, 0 = low). table 70. interrupt enable and priority 2 sfr (ieip2, 0xa9) bit mnemonic description 7 reserved 6 pti rtc interrupt priority (1 = high, 0 = low). 5 reserved 4 psi spi/i 2 c interrupt priority (1 = high, 0 = low). 3 eade enables the energy metering interrupt (ade). set by the user. 2 eti enables the rtc interval timer interrupt. set by the user. 1 epsm enables the psm power supply mana gement interrupt. set by the user. 0 esi enables the spi/i 2 c interrupt. set by the user. interrupt priority if two interrupts of the same priority level occur simultaneously, the polling sequence is observed (as shown in table 71 ). table 71. priority within interrupt level source priority description ipsm 0 (highest) power supply monitor interrupt. irtc 1 rtc interval timer interrupt. iade 2 ade energy measurement interrupt. wdt 3 watchdog timer overflow interrupt. itemp 4 temperature adc interrupt. ie0 5 external interrupt 0. tf0 6 timer/counter 0 interrupt. ie1 7 external interrupt 1. tf1 8 timer/counter 1 interrupt. ispi/i2ci 9 spi/i 2 c interrupt. ri/ti 10 uart serial port interrupt. tf2/exf2 11 (lowest) timer/counter 2 interrupt.
ADE7566/ade7569/ade7166/ade7169 rev. a | page 91 of 144 interrupt flags the interrupt flags and status flags associated with the interrupt vectors are shown in tabl e 72 and table 73 . most of the interrupts have flags associated with them. table 72. interrupt flags interrupt source flag bit address description ie0 tcon.1 ie0 external interrupt 0. tf0 tcon.5 tf0 timer 0. ie1 tcon.3 ie1 external interrupt 1. tf1 tcon.7 tf1 timer 1. scon.1 ti transmit interrupt. ri + ti scon.0 ri receive interrupt. t2con.7 tf2 timer 2 overflow flag. tf2 + exf2 t2con.6 exf2 timer 2 external flag. itemp (temperature adc) temperature adc interrupt. do es not have an interrupt flag associated with it. ipsm (power supply) ipsmf.6 fpsm psm interrupt flag. iade (energy measurement dsp) mirqstl.7 read mirqsth, mirqstm, mirqstl. table 73. status flags interrupt source flag bit address description itemp (temperature adc) temperature adc interrupt. does not have a status flag associated with it. spi2cstat spi interrupt status register. ispi/i2ci spi2cstat i 2 c interrupt status register. timecon.7 rtc midnight flag. irtc (rtc interval timer) timecon.2 rtc alarm flag. wdt (watchdog timer) wdcon.2 wds watchdog timeout flag. a functional block diagram of the interrupt system is shown in figure 88 . note that the psm interrupt is the only interrupt in the highest priority level. if an external wake-up event occurs to wake the ADE7566/ ade7569/ade7166/ade7169 from psm2, a pending external interrupt is generated. when the ex0 or ex1 bit in the interrupt enable sfr (ie, 0xa8) is set to enable external interrupts, the program counter is loaded with the ie0 or ie1 interrupt vector. the ie0 and ie1 interrupt flags in the tcon register are not affected by events that occur when the 8052 mcu core is shut down during psm2. see the power supply monitor interrupt (psm) section. the rtc, temperature adc, and i 2 c/spi interrupts are latched such that pending interrupts cannot be cleared without entering their respective interrupt service routines. clearing the rtc midnight flags and alarm flags does not clear a pending rtc interrupt. similarly, clearing the i 2 c/spi status bits in the spi interrupt status sfr (spistat, 0xea) does not cancel a pending i 2 c/spi interrupt. these interrupts remain pending until the rtc or i 2 c/spi interrupt vectors are enabled. their respective interrupt service routines are entered shortly thereafter. figure 88 shows how the interrupts are cleared when the interrupt service routines are entered. some interrupts with multiple interrupt sources are not automatically cleared; specifically, the psm, ade, uart, and timer 2 interrupt vectors. note that the int0 and int1 interrupts are only cleared if the external interrupt is configured to be triggered by a falling edge by setting it0 in the timer/counter 0 and timer/counter 1 control sfr (tcon, 0x88). if int0 or int1 is configured to interrupt on a low level, the interrupt service routine is reentered until the respective pin goes high.
ADE7566/ade7569/ade7166/ade7169 rev. a | page 92 of 144 ipsmf fpsm (ipsmf.6) ipsme individual interrupt enable ie/ieip2 registers ip/ieip2 registers watchdog timeout wdir low high highest midnight alarm in out latch reset mirqsth mirqstm mirqstl mirqenh mirqenm mirqenl mirqstl.7 tempadc interrupt in out latch reset int0 it0 0 1 ie0 tf0 int1 it1 0 1 tf1 cfg.5 0 1 i 2 c interrupt spi interrupt ri ti tf2 exf2 interrupt polling sequence psm rtc ade watchdog temp adc external interrupt 0 timer 0 external interrupt 1 timer 1 i 2 c/spi uart timer 2 automatic clear signal legend it0 ie1 it1 psm2 psm2 priority level global interrupt enable (ea) in out latch reset 0 6353-064 figure 88. interrupt system functional block diagram
ADE7566/ade7569/ade7166/ade7169 rev. a | page 93 of 144 interrupt vectors when an interrupt occurs, the program counter is pushed onto the stack, and the corresponding interrupt vector address is loaded into the program counter. when the interrupt service routine is complete, the program counter is popped off the stack by a reti instruction. this allows program execution to resume from where it was interrupted. the interrupt vector addresses are shown in table 74 . table 74. interrupt vector addresses source vector address ie0 0x0003 tf0 0x000b ie1 0x0013 tf1 0x001b ri + ti 0x0023 tf2 + exf2 0x002b itemp (temperature adc) 0x0033 ispi/i2ci 0x003b ipsm (power supply) 0x0043 iade (energy measurement dsp) 0x004b irtc (rtc interval timer) 0x0053 wdt (watchdog timer) 0x005b interrupt latency the 8052 architecture requires that at least one instruction execute between interrupts. to ensure this, the 8052 mcu core hardware prevents the program counter from jumping to an isr immediately after completing a reti instruction or an access of the ip and ie registers. the shortest interrupt latency is 3.25 instruction cycles, 800 ns with a clock of 4.096 mhz. the longest interrupt latency for a high priority interrupt results when a pending interrupt is generated during a low priority interrupt reti, followed by a multiply instruction. this results in a maximum interrupt latency of 16.25 instruction cycles, 4 s with a clock of 4.096 mhz. context saving when the 8052 vectors to an interrupt, only the program counter is saved on the stack. therefore, the interrupt service routine must be written to ensure that registers used in the main program are restored to their pre-interrupt state. common registers that can be modified in the isr are the accumulator register and the psw register. any general-purpose registers that are used as scratch pads in the isr should also be restored before exiting the interrupt. the following example 8052 code shows how to restore some commonly used registers: generalisr: ; save the current accumulator value push acc ; save the current status and register bank selection push psw ; service interrupt ? ; restore the status and register bank selection pop psw ; restore the accumulator pop acc reti
ADE7566/ade7569/ade7166/ade7169 rev. a | page 94 of 144 watchdog timer the watchdog timer generates a device reset or interrupt within a reasonable amount of time if the ADE7566/ade7569/ ade7166/ade7169 enter an erroneous state, possibly due to a programming error or electrical noise. the watchdog is enabled by default with a timeout of two seconds and creates a system reset if not cleared within two seconds. the watchdog function can be disabled by clearing the watchdog enable bit (wde) in the watchdog timer sfr (wdcon, 0xc0). the wdcon sfr can be written only by user software if the double write sequence described in table 75 is initiated on every write access to the wdcon sfr. to prevent any code from inadvertently disabling the watchdog, a watchdog protection can be activated. this watchdog protection locks in the watchdog enable and event settings so they cannot be changed by user code. the protection is activated by clearing a watchdog protection bit in the flash memory. the watchdog protection bit is the most significant bit at address 0x3ffa of the flash memory. when this bit is cleared, the wdir bit is forced to 0, and the wde bit is forced to 1. note that the sequence for configuring the flash protection bits must be followed to modify the watchdog protection bit at address 0x3ffa (see the the watchdog circuit generates a system reset or interrupt (wds) if the user program fails to set the wde bit within a predetermined amount of time (set by the pre[3:0] bits). the watchdog timer is clocked from the 32.768 khz external crystal connected between the clkin and clkout pins. protecting the flash memory section). table 75. watchdog timer sfr (wdcon, 0xc0) bit address mnemonic default description 7 to 4 pre[3:0] 7 0xc7 to 0xc4 watchdog prescaler. in normal mode, the 16- bit watchdog timer is clocked by the input clock (32.768 khz). the prex bits set which of th e upper bits of the counter are used as the watchdog output as follows: clki n t pre watchdog 9 2 2 = pre[3:0] result (watchdog timeout) 0000 15.6 ms 0001 31.2 ms 0010 62.5 ms 0011 125 ms 0100 250 ms 0101 500 ms 0110 1 sec 0111 2 sec 1000 0, automatic reset 1001 0, serial download reset 1010 to 1111 not a valid selection 3 0xc3 wdir 0 watchdog interrupt response bit. when cleared, the watchdog generates a system reset when the watchdog time out period has expired. when set, the watchdog generates an interrupt when the watchdog time out period has expired. 2 0xc2 wds 0 watchdog status bit. this bit is set to indica te that a watchdog timeout has occurred. it is cleared by writing a 0 or by an external hard ware reset. a watchdog reset does not clear wds; therefore, it can be used to distinguish between a watchdog reset and a hardware reset from the reset pin. 1 0xc1 wde 1 watchdog enable bit. when set, this bit enab les the watchdog and clears its counter. the watchdog counter is subsequently cleared agai n whenever wde is set. if the watchdog is not cleared within its selected timeout period, it generates a system reset or watchdog interrupt, depending on the wdir bit. 0 0xc0 wdwr 0 watchdog write enable bit. see the writing to the watchdog timer sfr (wdcon, 0xc0) section.
ADE7566/ade7569/ade7166/ade7169 rev. a | page 95 of 144 table 76. watchdog and flash protection byte in flash (flash address = 0x3ffa) bit mnemonic default description this bit holds the protection for the watchdog timer and the 7 th bit of the flash protection key. when this bit is cleared, the watchdog enable and event bits wde and wdir cannot be changed by user code. the watchdog configuration is then fixed to wdir = 0 and wde = 1. the watchdog timeout in pre[3:0] can still be modified by user code. 7 wdprot_protky7 1 the value of this bit is also used to set the flash pr otection key. if this bit is cleared to protect the watchdog, then the default value for the flash pr otection key is 0x7f instead of 0xff (see the protecting the flash memory section for more information on how to clear this bit). 6 to 0 protky[7:0] 0xff these bits hold the flash protection key. the co ntent of this flash address is compared to the flash protection key sfr (protky, 0xbb) when the protection is being set or changed. if the two values match, the new protection is written to the flash address 0x3fff to address 0x3ffb. see the protecting the flash memory section for more information on how to configure these bits. writing to the watchdog timer sfr (wdcon, 0xc0) writing data to the wdcon sfr involves a double instruction sequence. the wdwr bit must be set and the following instruction must be a write instruction to the wdcon sfr. disable watch dog clr ea setb wdwr clr wde setb ea this sequence is necessary to protect the wdcon sfr from code execution upsets that may unintentionally modify this sfr. interrupts should be disabled during this operation due to the consecutive instruction cycles. watchdog timer interrupt if the watchdog timer is not cleared within the watchdog timeout period, a system reset occurs unless the watchdog timer interrupt is enabled. the watchdog timer interrupt enable bit (wdir) is located in the watchdog timer sfr (wdcon, 0xc0). enabling the wdir bit allows the program to examine the stack or other variables that may have led the program to execute inappropriate code. the watchdog timer interrupt also allows the watchdog to be used as a long interval timer. note that wdir is automatically configured as a high priority interrupt. this interrupt cannot be disabled by the ea bit in the ie register (see table 68). even if all of the other interrupts are disabled, the watchdog is kept active to watch over the program.
ADE7566/ade7569/ade7166/ade7169 rev. a | page 96 of 144 lcd driver using shared pins, the lcd module is capable of directly driving an lcd panel of 17 4 segments without compromising any ADE7566/ade7569/ade7166/ade7169 functions. it is capable of driving lcds with 2, 3, and 4 multiplexing. the lcd waveform voltages generated through internal charge pump circuitry support up to 5 v lcds. an external resistor ladder for lcd waveform voltage generation is also supported. each ADE7566/ade7569/ade7166/ade7169 has an embedded lcd control circuit, driver, and power supply circuit. the lcd module is functional in all operating modes (see the operating modes section). lcd registers there are six lcd control registers that configure the driver for the specific type of lcd in the end system and set up the user display preferences. the lcd configuration sfr (lcdcon, 0x95), lcd configuration x sfr (lcdconx, 0x9c), and lcd configuration y sfr (lcdcony, 0xb1) contain general lcd driver configuration information including the lcd enable and reset, as well as the method of lcd voltage generation and multiplex level. the lcd clock sfr (lcdclk, 0x96) configures timing settings for lcd frame rate and blink rate. lcd pins are configured for lcd functionality in the lcd segment enable sfr (lcdsege, 0x97) and lcd segment enable 2 sfr (lcdsege2, 0xed). table 77. lcd driver sfrs sfr address r/w name description 0x95 r/w lcdcon lcd configuration sfr (see table 78 ). 0x96 r/w lcdclk lcd clock (see table 82 ). 0x97 r/w lcdsege lcd segment enable (see table 85 ). 0x9c r/w lcdconx lcd configuration x (see table 79 ). 0xac r/w lcdptr lcd pointer (see table 86 ). 0xae r/w lcddat lcd data (see table 87 ). 0xb1 r/w lcdcony lcd configuration y (see table 81 ). 0xed r/w lcdsege2 lcd segment enable 2 (see table 88 ). table 78. lcd configuration sfr (lcdcon, 0x95) bit mnemonic value description 7 lcden 0 lcd enable. if this bit is set, the lcd driver is enabled. 6 lcdrst 0 lcd data registers reset. if this bit is set, the lcd data registers are reset to zero. 5 blinken 0 blink mode enable bit. if this bit is set, blink mo de is enabled. the blink mode is configured by the blkmod[1:0] and blkfreq[1:0] bits in the lcd clock sfr (lcdclk, 0x96). forces lcd off when in psm2 (sleep mode). note that the internal voltage reference must be enabled by setting the ref_bat_en bit in the peripheral configuration sfr (periph, 0xf4) to allow lcd operation in psm2. lcdpsm2 result 0 the lcd is disabled or enabled in psm2 by the lcden bit. 4 lcdpsm2 0 1 the lcd is disabled in psm2 regardless of lcden setting. lcd clock selection. clksel result 0 f lcdclk = 2048 hz 3 clksel 0 1 f lcdclk = 128 hz bias mode. bias result 0 1/2 2 bias 0 1 1/3 lcd multiplex level. lmux[1:0] result 00 reserved. 01 2 multiplexing. fp27/com3 is used as fp27. fp28/com2 is used as fp28. 10 3 mulitplexing. fp27/com3 is used as fp27. fp28/com2 is used as com2. 1 to 0 lmux[1:0] 0 11 4 multiplexing. fp27/com3 is used as com3. fp28/com2 is used as com2.
ADE7566/ade7569/ade7166/ade7169 rev. a | page 97 of 144 table 79. lcd configuration x sfr (lcdconx, 0x9c) bit mnemonic default description 7 reserved 0 reserved. external resistor ladder selection bit. 6 extres 0 extres result 0 external resistor ladder is disabled. charge pump is enabled. 1 external resistor ladder is enab led. charge pump is disabled. 5 to 0 biaslvl[5:0] 0 bias level selection bits. see table 80 . table 80. lcd bias voltage when contrast control is enabled 1/2 bias 1/3 bias biaslvl[5] v a (v) v b v c v b v c [] 31 4:0blvl v ref 0 v b = v a v c = 2 v a v b = 2 v a v c = 3 v a [] ? ? ? ? ? ? + 31 1 4:0blvl v ref 1 v c = 2 v a v b = 2 v a v c = 3 v a v b = v a table 81. lcd configuration y sfr (lcdcony, 0xb1) bit mnemonic default description 7 reserved 0 this bit should be kept cleared for proper operation. 6 inv_lvl 0 frame inversion mode enable bit. if this bit is set, frames are inverted every other frame. if this bit is cleared, frames are not inverted. 5 to 2 reserved 0 these bits should be kept cleared for proper operation. 1 updateover 0 update finished flag bit. this bit is updated by th e lcd driver. when set, this bit indicates that the lcd memory has been updated and a new frame has begun. 0 refresh 0 refresh lcd data memory bit. this bit should be se t by the user. when set, the lcd driver does not use the data in the lcd data registers to update the display. the lcd data registers can be updated by the 8052. when cleared, the lcd driver uses the data in the lcd data registers to update display at the next frame. table 82. lcd clock sfr (lcdclk, 0x96) bit mnemonic default description blink mode clock source configuration bits. 7 to 6 blkmod[1:0] 0 blkmod[1:0] result 00 the blink rate is controlled by software. the display is off. 01 the blink rate is controlled by software. the display is on. 10 the blink rate is 2 hz. 11 the blink rate is set by blkfreq[1:0]. blink rate configuration bits. these bits control the lcd blink rate if blkmod[1:0] = 11. 5 to 4 blkfreq[1:0] 0 blkfreq[1:0] result (blink rate) 00 1 hz 01 1/2 hz 10 1/3 hz 11 1/4 hz 3 to 0 fd[3:0] 0 lcd frame rate selection bits. see table 83 and table 84 .
ADE7566/ade7569/ade7166/ade7169 rev. a | page 98 of 144 table 83. lcd frame rate selection for f lcdclk = 2048 hz (lcdcon[3] = 0) 2 multiplexing 3 multiplexing 4 multiplexing fd3 fd2 fd1 fd0 f lcd (hz) frame rate (hz) f lcd (hz) frame rate (hz) f lcd (hz) frame rate (hz) 0 0 0 1 256 128 1 341.3 170.7 1 512 128 1 0 0 1 0 170.7 85.3 341.3 113.8 1 341.3 85.3 0 0 1 1 128 64 256 85.3 256 64 0 1 0 0 102.4 51.2 204.8 68.3 204.8 51.2 0 1 0 1 85.3 42.7 170.7 56.9 170.7 42.7 0 1 1 0 73.1 36.6 146.3 48.8 146.3 36.6 0 1 1 1 64 32 128 42.7 128 32 1 0 0 0 56.9 28.5 113.8 37.9 113.8 28.5 1 0 0 1 51.2 25.6 102.4 34.1 102.4 25.6 1 0 1 0 46.5 23.25 93.1 31 93.1 23.25 1 0 1 1 42.7 21.35 85.3 28.4 85.3 21.35 1 1 0 0 39.4 19.7 78.8 26.3 78.8 19.7 1 1 0 1 36.6 18.3 73.1 24.4 73.1 18.3 1 1 1 0 34.1 17.05 68.3 22.8 68.3 17.05 1 1 1 1 32 16 64 21.3 64 16 0 0 0 0 16 8 32 10.7 32 8 1 not within the range of typical lcd frame rates. table 84. lcd frame rate selection for f lcdclk = 128 hz (lcdcon[3] = 1) 2 multiplexing 3 multiplexing 4 multiplexing fd3 fd2 fd1 fd0 f lcd (hz) frame rate (hz) f lcd (hz) frame rate (hz) f lcd (hz) frame rate (hz) 0 0 0 1 32 16 1 32 10.7 32 8 0 0 1 0 21.3 10.6 32 10.7 32 8 0 0 1 1 16 8 32 10.7 32 8 0 1 0 0 16 8 32 10.7 32 8 0 1 0 1 16 8 32 10.7 32 8 0 1 1 0 16 8 32 10.7 32 8 0 1 1 1 16 8 32 10.7 32 8 1 0 0 0 16 8 32 10.7 32 8 1 0 0 1 16 8 32 10.7 32 8 1 0 1 0 16 8 32 10.7 32 8 1 0 1 1 16 8 32 10.7 32 8 1 1 0 0 16 8 32 10.7 32 8 1 1 0 1 16 8 32 10.7 32 8 1 1 1 0 16 8 32 10.7 32 8 1 1 1 1 128 64 128 42.7 128 32 0 0 0 0 64 32 64 21.3 64 16 1 not within the range of typical lcd frame rates. table 85. lcd segment enable sfr (lcdsege, 0x97) bit mnemonic default description 7 fp25en 0 fp25 function select bit. 0 = general-purpose i/o, 1 = lcd function. 6 fp24en 0 fp24 function select bit. 0 = general-purpose i/o, 1 = lcd function. 5 fp23en 0 fp23 function select bit. 0 = general-purpose i/o, 1 = lcd function. 4 fp22en 0 fp22 function select bit. 0 = general-purpose i/o, 1 = lcd function. 3 fp21en 0 fp21 function select bit. 0 = general-purpose i/o, 1 = lcd function. 2 fp20en 0 fp20 function select bit. 0 = general-purpose i/o, 1 = lcd function. 1 to 0 reserved 0 these bits should be left at 0 for proper operation.
ADE7566/ade7569/ade7166/ade7169 rev. a | page 99 of 144 table 86. lcd pointer sfr (lcdptr, 0xac) bit mnemonic default description 7 r /w 0 read or write lcd bit. if this bit is set (1), the data in lcddat is written to the address indicated by the lcdptr[5:0] bits. 6 reserved 0 reserved. 5 to 0 address 0 lcd memory address (see table 89). table 87. lcd data sfr (lcddat, 0xae) bit mnemonic default description 7 to 0 lcddata 0 data to be written into or read out of the lcd memory sfrs. table 88. lcd segment enable 2 sfr (lcdsege2, 0xed) bit mnemonic default description 7 to 4 reserved 0 reserved. 3 fp19en 0 fp19 function select bit. 0 = general-purpose i/o, 1 = lcd function. 2 fp18en 0 fp18 function select bit. 0 = general-purpose i/o, 1 = lcd function. 1 fp17en 0 fp17 function select bit. 0 = general-purpose i/o, 1 = lcd function. 0 fp16en 0 fp16 function select bit. 0 = general-purpose i/o, 1 = lcd function. lcd setup the lcd configuration sfr (lcdcon, 0x95) configures the lcd module to drive the type of lcd in the user end system. the bias and lmux[1:0] bits in this sfr should be set according to the lcd specifications. the com2/fp28 and com3/fp27 pins default to lcd segment lines. selecting the 3 multiplex level in the lcd configuration sfr (lcdcon, 0x95) by setting lmux[1:0] to 2d changes the fp28 pin functionality to com2. the 4 multiplex level selection, lmux[1:0] = 3d, changes the fp28 pin functionality to com2 and the fp27 pin functionality to com3. lcd segments fp0 to fp15 and fp26 are enabled by default. additional pins are selected for lcd functionality in the lcd segment enable sfr (lcdsege, 0x97) and lcd segment enable 2 sfr (lcdsege2, 0xed) where there are individual enable bits for the fp16 to fp25 segment pins. the lcd pins do not have to be enabled sequentially. for example, if the alternate function of fp23, the timer 2 input, is required, any of the other shared pins, fp16 to fp25, can be enabled instead. the display element control section contains details about setting up the lcd data memory to turn individual lcd segments on and off. setting the lcdrst bit in the lcd configuration sfr (lcdcon, 0x95) resets the lcd data memory to its default (0). a power-on reset also clears the lcd data memory. lcd timing and waveforms an lcd segment acts like a capacitor that is charged and discharged at a certain rate. this rate, the refresh rate, determines the visual characteristics of the lcd. a slow refresh rate results in the lcd blinking on and off between refreshes. a fast refresh rate presents a screen that appears to be continuously lit. in addition, a faster refresh rate consumes more power. the frame rate, or refresh rate, for the lcd module is derived from the lcd clock, f lcdclk . the lcd clock is selected as 2048 hz or 128 hz by the clksel bit in the lcd configuration sfr (lcdcon, 0x95). the minimum refresh rate needed for the lcd to appear solid (without blinking) is independent of the multiplex level. the lcd waveform frequency, f lcd , is the frequency at which the lcd switches the active common line. thus, the lcd waveform frequency depends heavily on the multiplex level. the frame rate and lcd waveform frequency are set by f lcdclk , the multiplex level, and the fd[3:0] frame rate selection bits in the lcd clock sfr (lcdclk, 0x96). the lcd module provides 16 different frame rates for f lcdclk = 2048 hz, ranging from 8 hz to 128 hz for an lcd with 4 multiplexing. fewer options are available with f lcdclk = 128 hz, ranging from 8 hz to 32 hz for a 4 multiplexed lcd. the 128 hz clock is beneficial for battery operation because it consumes less power than the 2048 hz clock. the frame rate is set by the fd[3:0] bits in the lcd clock sfr (lcdclk, 0x96); see table 83 and table 84. the lcd waveform is inverted at twice the lcd waveform frequency, f lcd . this way, each frame has an average dc offset of zero. adc offset degrades the lifetime and performance of the lcd.
ADE7566/ade7569/ade7166/ade7169 rev. a | page 100 of 144 blink mode blink mode is enabled by setting the blinken bit in the lcd configuration sfr (lcdcon, 0x95). this mode is used to alternate between the lcd on state and lcd off state so that the lcd screen appears to blink. there are two blinking modes: a software controlled blink mode and an automatic blink mode. software controlled blink mode the lcd blink rate can be controlled by user code with the blkmod[1:0] bits in the lcd clock sfr (lcdclk, 0x96) by toggling the bits to turn the display on and off at a rate determined by the mcu code. automatic blink mode there are five blink rates available if the rtc peripheral is enabled by setting the rtcen bit in the rtc configuration sfr (timecon, 0xa1). these blink rates are selected by the blkmod[1:0] and blkfreq[1:0] bits in the lcd clock sfr (lcdclk, 0x96); see table 82 . display element control a bank of 15 bytes of data memory located in the lcd module controls the on or off state of each lcd segment. the lcd data memory is stored in address 0 through address 14 in the lcd module. each byte configures the on and off states of two segment lines. the lsbs store the state of the even numbered segment lines, and the msbs store the state of the odd numbered segment lines. for example, lcd data address 0 refers to segment lines one and zero (see table 89 ). note that the lcd data memory is maintained in psm2 operating mode. the lcd data memory is accessed indirectly through the lcd pointer sfr (lcdptr, 0xac) and lcd data sfr (lcddat, 0xae). moving a value to the lcdptr sfr selects the lcd data byte to be accessed and initiates a read or write operation (see table 86 ). writing to lcd data registers to update the lcd data memory, first set the lsb of the lcd configuration y sfr (lcdcony, 0xb1) to freeze the data being displayed on the lcd while updating it. then, move the data to the lcd data sfr (lcddat, 0xae) prior to accessing the lcd pointer sfr (lcdptr, 0xac). when the msb of the lcdptr sfr is set, the content of the lcddat sfr is transferred to the internal lcd data memory designated by the address in the lcdptr sfr. clear the lsb of the lcd configuration y sfr (lcdcony, 0xb1) when all of the data memory has been updated to allow the use of the new lcd setup for display. to update the segments attached to the fp10 and fp11 pins, use the following sample 8052 code: orl lcdcony,#01h ;start updating the data mov lcddata,#ffh mov lcdptr,#80h or 05h anl lcdcony,#0feh ;update finished reading lcd data registers when the msb of the lcd pointer sfr (lcdptr, 0xac) is cleared, the content of the lcd data memory address designated by lcdptr is transferred to the lcd data sfr (lcddat, 0xae). sample 8052 code to read the contents of lcd data memory address 0x07, which holds the on and off state of the segments attached to fp14 and fp15, is as follows. mov lcdptr,#07h mov r1, lcddata table 89. lcd data memory acce ssed indirectly through lcd pointer sfr (lcd ptr, 0xac) and lcd data sfr (lcddat, 0xae) 1 , 2 lcd pointer sfr (lcdptr, 0xac) lcd pointer sfr (lcddat, 0xae) lcd memory address com3 com2 com1 com0 com3 com2 com1 com0 0x0e fp28 fp28 fp28 fp28 0x0d fp27 fp27 fp27 fp27 fp26 fp26 fp26 fp26 0x0c fp25 fp25 fp25 fp25 fp24 fp24 fp24 fp24 0x0b fp23 fp23 fp23 fp23 fp22 fp22 fp22 fp22 0x0a fp21 fp21 fp21 fp21 fp20 fp20 fp20 fp20 0x09 fp19 fp19 fp19 fp19 fp18 fp18 fp18 fp18 0x08 fp17 fp17 fp17 fp17 fp16 fp16 fp16 fp16 0x07 fp15 fp15 fp15 fp15 fp14 fp14 fp14 fp14 0x06 fp13 fp13 fp13 fp13 fp12 fp12 fp12 fp12 0x05 fp11 fp11 fp11 fp11 fp10 fp10 fp10 fp10 0x04 fp9 fp9 fp9 fp9 fp8 fp8 fp8 fp8 0x03 fp7 fp7 fp7 fp7 fp6 fp6 fp6 fp6 0x02 fp5 fp5 fp5 fp5 fp4 fp4 fp4 fp4 0x01 fp3 fp3 fp3 fp3 fp2 fp2 fp2 fp2 0x00 fp1 fp1 fp1 fp1 fp0 fp0 fp0 fp0 1 comx designates the common lines. 2 fpx designates the segment lines.
ADE7566/ade7569/ade7166/ade7169 rev. a | page 101 of 144 voltage generation lcd external circuitry the ADE7566/ade7569/ade7166/ade7169 provide two ways to generate the lcd waveform voltage levels. the on-chip charge pump option can generate 5 v. this makes it possible to use 5 v lcds with the 3.3 v ADE7566/ade7569/ade7166/ ade7169. there is also an option to use an external resistor ladder with a 3.3 v lcd. the extres bit in the lcd configuration x sfr (lcdconx, 0x9c) selects the resistor ladder or charge pump option. the voltage generation selection is made by bit extres in the lcd configuration x sfr (lcdconx, 0x9c). this bit is cleared by default for charge pump voltage generation, but can be set to enable an external resistor ladder. charge pump voltage generation through the charge pump requires external capacitors to store charge. the external connections to lcdva, lcdvb, and lcdvc, as well as lcdvp1 and lcdvp2, are shown in when selecting how to generate the lcd waveform voltages, the following should be considered: figure 89 . lcdvc lcdvb lcdva lcdvp1 lcdvp2 charge pump and lcd waveform circuitry 100nf 470nf 470nf 470nf 06353-065 ? lifetime performance power consumption ? contrast control lifetime performance power consumption in most lcds, a high amount of current is required when the lcd waveforms change state. the external resistor ladder option draws a constant amount of current, whereas the charge pump circuitry allows dynamic current consumption. if the lcd module is used with the internal charge pump option when the display is disabled, the voltage generation is disabled, so that no power is consumed by the lcd function. this feature results in significant power savings if the display is turned off during battery operation. figure 89. external circuitry for charge pump option external resistor ladder to enable the external resistor ladder option, set the extres bit in the lcd configuration x sfr (lcdconx, 0x9c). when extres = 1, the lcd waveform voltages are supplied by the external resistor ladder. because the lcd voltages are not generated on-chip, the lcd bias compensation implemented to maintain contrast over temperature and supply is not possible. contrast control the electrical characteristics of the liquid in the lcd change over temperature. this requires adjustments in the lcd waveform voltages to ensure a readable display. an added benefit of the internal charge pump voltage generation is a configurable bias voltage that can be compensated over temperature and supply to maintain contrast on the lcd. these compensations can be performed based on the ADE7566/ade7569/ade7166/ ade7169 temperature and supply voltage measurements (see the the external circuitry needed for the resistor ladder option is shown in figure 90 . the resistors required should be in the range of 10 k to 100 k and based on the current required by the lcd being used. lcdvc lcdvb lcdva lcdvp1 lcdvp2 lcd waveform circuitry 06353-066 temperature, battery, and supply voltage measurements section). this dynamic contrast control is not easily implemented with external resistor ladder voltage generation. figure 90. external circuitry for external resistor ladder option the lcd bias voltage sets the contrast of the display when the charge pump provides the lcd waveform voltages. the ADE7566/ ade7569/ade7166/ade7169 provide 64 bias levels selected by the biaslvl bits in the lcd configuration x sfr (lcdconx, 0x9c). the voltage level on lcdva, lcdvb and lcdvc depend on the internal voltage reference value (v ref ), biaslvl[5:0] selection, and the biasing selected as described in lcd function in psm2 the lcdpsm2 and lcden bits in the lcd configuration sfr (lcdcon, 0x95) control lcd functionality in the psm2 operating mode (see table 90 ). note that the internal voltage reference must be enabled by setting the ref_bat_en bit in the peripheral configuration sfr (periph, 0xf4) to allow lcd operation in psm2 (see table 80 . lifetime performance table 19 ). dc offset on a segment degrades its performance over time. the voltages generated through the internal charge pump switch faster than those generated by the external resistor ladder, reducing the likelihood of a dc voltage being applied to a segment and increasing the lifetime of the lcd.
ADE7566/ade7569/ade7166/ade7169 rev. a | page 102 of 144 table 90. bits controlling lcd functionality in psm2 mode lcdpsm2 lcden result 0 0 the display is off in psm2. 0 1 the display is on in psm2. 1 x the display is off in psm2. in addition, note that the lcd configuration and data memory is retained when the display is turned off. example lcd setup an example of how to set up the lcd peripheral for a specific lcd is described in this section with the following parameters: ? type of lcd: 5 v, 4 multiplexed with 1/3 bias, 96 segment ? voltage generation: internal charge pump ? refresh rate: 64 hz a 96-segment lcd with 4 multiplexing requires 96/4 = 24 segment lines. sixteen pins, fp0 to fp15, are automatically dedicated for use as lcd segments. eight more pins must be chosen for the lcd function. because the lcd has 4 multi- plexing, all four common lines are used. as a result, com2/fp28 and com3/fp27 cannot be used as segment lines. based on the alternate functions of the pins used for fp16 through fp25, fp16 to fp23 are chosen for the eight remaining segment lines. these pins are enabled for lcd functionality in the lcd segment enable sfr (lcdsege, 0x97) and lcd segment enable 2 sfr (lcdsege2, 0xed). to determine contrast setting for this 5 v lcd, table 80 shows the biaslvl[5:0] setting that corresponds to a vc of 5 v in 1/3 bias mode. the maximal bias level setting for this lcd is biaslvl[5:0] = [101110]. the lcd is setup with the following 8052 code: ; setup lcd pins to have lcd functionality mov lcdseg,#fp20en+fp21en+fp22en+fp23en mov lcdsegx,#fp16en+fp17en+fp18en+fp19en ; setup lcdcon for f lcdclk =2048hz, 1/3 bias and 4x multiplexing mov lcdcon,#bias+lmux1+lmux0 ; setup lcdconx for charge pump and biaslvl[110111] mov lcdconx,#biaslvl5+biaslvl4+biaslvl3+biaslvl2+biaslvl1+biaslvl0 ; set up refresh rate for 64hz with f lcdclk =2048hz mov lcdclk,#fd3+fd2+fd1+fd0 ; set up lcd data registers with data to be displayed using ; lcdptr and lcddata registers ; turn all segments on fp27 on and fp26 off orl lcdcony,#01h ; start data memory refresh mov lcddat,#f0h mov lcdptr, #80h or 0dh anl lcdcony,#0feh ; end of data memory refresh orl lcdcon,#lcden ; enable lcd to setup the same 3.3 v lcd for use with an external resistor ladder: ; setup lcdconx for external resistor ladder mov lcdconx,#extres
ADE7566/ade7569/ade7166/ade7169 rev. a | page 103 of 144 flash memory in reliability qualification, every byte in both the program and data flash/ee memory is cycled from 0x00 to 0xff until a first fail is recorded, signifying the endurance limit of the on-chip flash/ee memory. overview flash memory is a type of nonvolatile memory that is in-circuit programmable. the default state of a byte of flash memory is 0xff (erased). when a byte of flash memory is programmed, the required bits change from 1 to 0. the flash memory must be erased to turn the 0s back to 1s. however, a byte of flash memory cannot be erased individually. the entire segment, or page, of flash memory that contains the byte must be erased. as indicated in the specifications section, the ADE7566/ade7569/ ade7166/ade7169 flash memory endurance qualification has been carried out in accordance with jedec standard 22 method a117 over the industrial temperature range of ?40c, +25c, and +85c. the results allow the specification of a minimum endurance figure over supply and temperature of 100,000 cycles, with a minimum endurance figure of 20,000 cycles of operation at 25c. the ADE7566/ade7569/ade7166/ade7169 provide 16 kb of flash program/ information memory. this memory is segmented into 32 pages of 512 bytes each. therefore, to reprogram one byte of flash memory, the other 511 bytes in that page must be erased. the flash memory can be erased by page or all at once in a mass erase. there is a command to verify that a flash write operation has completed successfully. the ADE7566/ade7569/ ade7166/ade7169 flash memory controller also offers configurable flash memory protection. retention is the ability of the flash memory to retain its programmed data over time. again, the parts have been qualified in accordance with the formal jedec standard 22 method a117 at a specific junction temperature (t j = 55c). as part of this qualification procedure, the flash memory is cycled to its specified endurance limit before data retention is characterized. this means that the flash memory is guaranteed to retain its data for its full specified retention lifetime every time the flash memory is reprogrammed. it should also be noted that retention lifetime, based on an activation energy of 0.6 ev, derates with t j as shown in the 16 kb of flash memory are provided on-chip to facilitate code execution without any external discrete rom device requirements. the program memory can be programmed in- circuit, using the serial download or emulation options provided or using conventional third party memory programmers. figure 91 . flash/ee memory reliability 40 60 70 90 t j junction temperature (c) retention (years) 250 200 150 100 50 0 50 80 110 300 100 analog devices specification 100 years min. at t j = 55 c 0 6353-067 the flash memory arrays on the ADE7566/ade7569/ ade7166/ade7169 are fully qualified for two key flash/ee memory characteristics: flash/ee memory cycling endurance and flash/ee memory data retention. endurance quantifies the ability of the flash/ee memory to be cycled through many program, read, and erase cycles. in real terms, a single endurance cycle is composed of the following four independent, sequential events: 1. initial page erase sequence. 2. read/verify sequence. 3. byte program sequence. 4. second read/verify sequence. figure 91. flash/ee memory data retention
ADE7566/ade7569/ade7166/ade7169 rev. a | page 104 of 144 the implication of write/erase protecting the last page is that the content of the 506 bytes in this page that are available to the user must not change. flash memory organization the 16 kb of flash memory provided by the ADE7566/ade7569/ ade7166/ade7169 are segmented into 32 pages of 512 bytes each. it is up to the user to decide which flash memory to allocate for data memory. it is recommended that each page be dedicated solely to program memory or data memory. doing so prevents the program counter from being loaded with data memory instead of an operations code from the program memory. it also prevents program memory used to update a byte of data memory from being erased. thus, if code protection is enabled, it is recommended to use this last page for program memory only (if the firmware does not need to be updated in the field). if the firmware must be protected and can be updated at a future date, the last page should be used only for constants utilized by the program code. therefore, page 0 through page 30 are for general program and data memory use. it is recommended that page 31 be used for constants or code that do not need to be updated. note that the last six bytes of page 31 are reserved for protecting the flash memory. 0x3e00 0x3dff 0x3c00 0x3bff 0x3a00 0x39ff 0x3800 0x37ff 0x3600 0x35ff 0x3400 0x33ff 0x3200 0x31ff 0x3000 0x2fff 0x2e00 0x2dff 0x2c00 0x2bff 0x2a00 0x29ff 0x2800 0x27ff 0x2600 0x25ff 0x2400 0x23ff 0x2200 0x21ff 0x2000 0x3fff contains protection settings. read protect bit 7 read protect bit 6 read protect bit 5 read protect bit 4 page 30 page 29 page 28 page 27 page 26 page 25 page 24 page 23 page 22 page 21 page 20 page 19 page 18 page 17 page 16 page 31 0x1e00 0x1dff 0x1c00 0x1bff 0x1a00 0x19ff 0x1800 0x17ff 0x1600 0x15ff 0x1400 0x13ff 0x1200 0x11ff 0x1000 0x0fff 0x0e00 0x0dff 0x0c00 0x0bff 0x0a00 0x09ff 0x0800 0x07ff 0x0600 0x05ff 0x0400 0x03ff 0x0200 0x01ff 0x0000 0x1ff f read protect bit 3 read protect bit 2 read protect bit 1 read protect bit 0 page 14 page 13 page 12 page 11 page 10 page 9 page 8 page 7 page 6 page 5 page 4 page 3 page 2 page 1 page 0 page 15 06353-068 using the flash memory the 16 kb of flash memory are configured as 32 pages, each of 512 bytes. as with the other ADE7566/ade7569/ade7166/ ade7169 peripherals, the interface to this memory space is via a group of registers mapped in the sfr space (see table 91 ). a data register, edata, holds the byte of data to be accessed. the byte of flash memory is addressed via the eadrh and eadrl registers. finally, econ is an 8-bit control register that can be written to with one of seven flash memory access commands to trigger various read, write, erase, and verify functions. table 91. the flash sfrs figure 92. flash memory organization the flash memory can be protected from read or write/erase (w/e) access. the protection is implemented in part of the last page of the flash memory, page 31. four of the bytes from this page are used to set up write/erase protection for each page. another byte is used for configuring read protection of the flash memory. the read protection is selected for groups of four pages. finally, one byte is used to store the key required for modifying the protection scheme. the last page of flash memory must be write/erase protected for any flash protection to be active. sfr address default bit address- able description econ 0xb9 0x00 no flash control. flshky 0xba 0xff no flash key. protky 0xbb 0xff no flash protection key. edata 0xbc 0x00 no flash data. protb0 0xbd 0xff no flash w/e protection 0. protb1 0xbe 0xff no flash w/e protection 1. protr 0xbf 0xff no flash read protection. eadrl 0xc6 0x00 no flash low byte address. eadrh 0xc7 0x00 no flash high byte address. figure 93 demonstrates the steps required for access to the flash memory. eadrh flshky eadrl address address decoder flshky = 0 3b? protection decoder econ command access allowed? flash protection key true: access allowed econ = 0 false: access denied econ = 1 0 6353-069 figure 93. flash memory read/write/erase protection block diagram
ADE7566/ade7569/ade7166/ade7169 rev. a | page 105 of 144 econflash/ee memory control sfr programming flash memory is done through the flash control sfr (econ, 0xb9). this sfr allows the user to read, write, erase, or verify the 16 kb of flash memory. as a method of security, a key must be written to the flshky register to initiate any user access to the flash memory. upon completion of the flash memory operation, the flshky register is reset so that it must be written to prior to another flash memory operation. requiring the key to be set before an access to the flash memory decreases the likelihood of user code or data being overwritten by a program inappropriately modified during its execution. the program counter (pc) is held on the instruction where the econ register is written to until the flash memory controller is done performing the requested operation. then, the pc increments to continue with the next instruction. any interrupt requests that occur while the flash controller is performing an operation are not handled until the flash operation is complete. all peripherals, such as timers and counters, continue to operate as configured throughout the flash memory access. table 92. flash control sfr (econ, 0xb9) bit mnemonic value description 7 to 0 econ 1 write byte. the value in edata is written to the fl ash memory at the page address given by eadrh and eadrl. note that the byte being addressed must be pre-erased. 2 erase page. a 512-byte page of flash memory address is erased. the page is selected by the address in eadrh/eadrl. any address in the page can be written to eadrh/eadrl to select it for erasure. 3 erase all. all 16 kb of the flash memory are erased. note that this command is used during serial and parallel download modes but should not be executed by user code. 4 read byte. the byte in the flash memory addressed by eadrh/eadrl is read into edata. 5 erase page and write byte. the page that holds the byte addressed by eadrh/eadrl is erased. data in edata is then written to the byte of flash memory addressed by eadrh/eadrl. 8 protect code (see the protecting the flash memory section). table 93. flash key sfr (flshky, 0xba) bit mnemonic default description 7 to 0 flshky 0xff the content of this sfr is compared to the flash ke y, 0x3b. if the two values match, the next econ operation is allowed (see the protecting the flash memory section). table 94. flash protection key sfr (protky, 0xbb) bit mnemonic default description 7 to 0 protky 0xff the content of this sfr is compared to the flash me mory location at address 0x3ffa. if the two values match, the update of the write/erase and re ad protection set up is allowed (see the protecting the flash memory section). if the protection key in the flash is 0xff, the protky sfr value is not used for comparison. this sfr is also used to write the protection key in the flash. this is done by writing the desired value in protky and by writing 0x08 in the econ sfr. this operation can only be done once. table 95. flash data sfr (edata, 0xbc) bit mnemonic default description 7 to 0 edata 0 flash pointer data. table 96. flash write/erase protection 0 sfr (protb0, 0xbd) bit mnemonic default description 7 to 0 protb0 0xff this sfr is used to write the write/erase protection bits for page 0 to page 7 of the flash memory (see the protecting the flash memory section). clearing the bits enables the protection. protb0.7 protb0.6 protb0.5 protb0.4 protb0.3 protb0.2 protb0.1 protb0.0 page 7 page 6 page 5 page 4 page 3 page 2 page 1 page 0 table 97. flash write/erase protection 1 sfr (protb1, 0xbe) bit mnemonic default description 7 to 0 protb1 0xff this sfr is used to write the write/erase protection bits for page 8 to page15 of the flash memory (see the protecting the flash memory section). clearing the bits enables the protection. protb1.7 protb1.6 protb1.5 protb1.4 protb1.3 protb1.2 protb1.1 protb1.0 page 15 page 14 page 13 page 12 page 11 page 10 page 9 page 8
ADE7566/ade7569/ade7166/ade7169 rev. a | page 106 of 144 table 98. flash read prot ection sfr (protr, 0xbf) bit mnemonic default description 7 to 0 protr 0xff this sfr is used to write the read protection bi ts for page 0 to page 31 of the flash memory (see the protecting the flash memory section). clearing the bits enables the protection. protr.7 protr.6 protr.5 protr.4 protr.3 protr.2 protr.1 protr.0 page 28 to page 31 page 24 to page 27 page 20 to page 23 page 16 to page 19 page 12 to page 15 page 8 to page 11 page 4 to page 7 page 0 to page 3 table 99. flash low byte address sfr (eadrl, 0xc6) bit mnemonic default description 7 to 0 eadrl 0 flash pointer low byte address. this sfr is also used to write the write/erase protection bits for page 16 to page 23 of the flash memory (see the protecting the flash memory section). clearing the bits enables the protection. eadrl.7 eadrl.6 eadrl.5 eadrl.4 eadrl.3 eadrl.2 eadrl.1 eadrl.0 page 23 page 22 page 21 page 20 page 19 page 18 page 17 page 16 table 100. flash high byte address sfr (eadrh, 0xc7) bit mnemonic default description 7 to 0 eadrh 0 flash pointer high byte address. this sfr is also used to write the write/erase protection bits for page 24 to page 31 of the flash memory (see the protecting the flash memory section). clearing the bits enables the protection. eadrh.7 eadrh.6 eadrh.5 eadrh.4 e adrh.3 eadrh.2 eadrh.1 eadrh.0 page 31 page 30 page 29 page 28 page 27 page 26 page 25 page 24 flash functions sample 8052 code is provided in this section to demonstrate how to use the flash functions. for these examples, the byte of flash memory 0x3c00 is accessed. write by te write 0xf3 into flash memory byte 0x3c00. mov edata,#f3h ; data to be written mov eadrh,#3ch ; setup byte address mov eadrl,#00h mov flshky,#3bh ; write flash security key. mov econ,#01h ; write byte erase page erase the page containing flash memory byte 0x3c00. mov eadrh,#3ch ; select page through byte address mov eadrl,#00h mov flshky,#3bh ; write flash security key. mov econ,#02h ; erase page erase all erase all of the 16 kb flash memory. mov flshky,#3bh ; write flash security key. mov econ,#03h ; erase all read byte read flash memory byte 0x3c00. mov eadrh,#3ch ; setup byte address mov eadrl,#00h mov flshky,#3bh ; write flash security key. mov econ,#04h ; read byte ; data is ready in edata register erase page and write byte erase the page containing flash memory byte 0x3c00 and then write 0xf3 to that address. note that the other 511 bytes in this page are erased. mov edata,#f3h ; data to be written mov eadrh,#3ch ; setup byte address mov eadrl,#00h mov flshky,#3bh ; write flash security key. mov econ,#05h ; erase page and then write byte
ADE7566/ade7569/ade7166/ade7169 rev. a | page 107 of 144 the sequence for writing the protection bits is as follows: protecting the flash memory 1. set up the eadrh, eadrl, protb1, and protb0 registers with the write/erase protection bits. when erased, the protection bits default to 1 (like any other bit of flash memory). the default protection setting is for no protection. to enable protection, write a 0 to the bits corresponding to the pages that should be protected. two forms of protection are offered for this flash memory: read protection and write/erase protection. the read protection ensures that any pages that are read protected are not able to be read by the end user. the write protection ensures that the flash memory cannot be erased or written over. this protects the end system from tampering and can prevent the code from being overwritten in the event of a unexpected disruption of the normal execution of the program. 2. set up the protr register with the read protection bits. note that every read protection bit protects four pages. to enable the read protection bit, write a 0 to the bits that should be read protected. write/erase protection is individually selectable for all 32 pages. read protection is selected in groups of 4 pages (see figure 92 for the groupings). the protection bits are stored in the last flash memory locations, address 0x3ffa through address 0x3fff (see 3. to enable the protection key, write to the protky register. if enabled, the protection key is required to modify the protection scheme. the protection key, flash memory address 0x3ffa, defaults to 0xff; if the protky register is not written to, it remains 0xff. if the protection key is written to, the protky register must be written with this value every time the protection functionality is accessed. note that once the protection key is configured, it cannot be modified. also note that the most significant bit of address 0x3ffa is used to enable a lock mechanism for the watchdog settings (see the figure 94 ); four bytes are reserved for write/erase protection, one byte is for read protection, and another byte sets the protection security key. the user must enable read and write/erase protection for the last page for the entire protection scheme to work. note that the read protection does not prevent movc commands from being executed within the code. watc hdo g ti me r section for more information). there is an additional layer of protection offered by a protection security key. the user can set up this security key so that the protection scheme cannot be changed without this key. once the protection key has been configured, it cannot be modified. 4. run the protection command by writing 0x08 to the econ register. 5. reset the chip to activate the new protection. enabling flash protection by code to enable read and write/erase protection for the last page only, use the following 8052 code. writing the flash protection command to the econ register initiates programming of the protection bits in the flash. the protection bytes in the flash memory can be programmed using the flash controller comma nd and programming econ to 0x08. in this case, the eadrh, eadrl, protb1, and protb0 bytes are used to store the data to be written to the 32 bits of write protection. note that the eadrh and eadrl registers are not used as data pointers here but to store write protection data. ; enable read protection on the last four pages only mov protr,#07fh 06353-070 protr protky protb0 protb1 eadrl eadrh rp 31:28 rp 27:24 rp 23:20 rp 19:16 rp 15:12 rp 11:8 rp 7:4 rp 3:0 wp 7 wp 6 wp 5 wp 4 wp 3 wp 2 wp 1 wp 0 wp 15 wp 14 wp 13 wp 12 wp 11 wp 10 wp 9 wp 8 wp 23 wp 22 wp 21 wp 20 wp 19 wp 18 wp 17 wp 16 wp 31 wp 30 wp 29 wp 28 wp 27 wp 26 wp 25 wp 24 protection key 0x3fff 0x3ffe 0x3ffd 0x3ffc 0x3ffb 0x3ffa 0x3ff9 0x3e00 wdog lock ; set up a protection key of 0a3h. this command can be ; omitted to use the default protection key of 0xff mov protky,#0a3h ; write the flash key to the flshky register to enable flash ; access. the flash access key is not configurable. mov flshky,#3bh ; write flash protection command to the econ register figure 94. flash protection in page 31 mov econ,#08h
ADE7566/ade7569/ade7166/ade7169 rev. a | page 108 of 144 enabling flash protection by emulator commands another way to set the flash protection bytes is to use some reserved emulator commands available only in download mode. these commands write directly to the sfrs and can be used to duplicate the operation mentioned in the enabling flash protection by code section. when these flash bytes are written, the part can exit emulation mode by a reset and the protections are effective. this method can be used in production and implemented after downloading the program. the commands used for this operation are an extension of the commands listed in the application note uc004: understanding the serial download protocol , available at www.analog.com . ? command with ascii code i or 0x49 writes the data into r0. ? command with ascii code f or 0x46 writes r0 into the sfr address defined in the data of this command. by omitting the protocol defined in the uc004: understanding the serial download protocol application note, the sequence to load protections is similar to the sequence presented in the enabling flash protection by code section, except that two emulator commands are necessary to replace one assembly command. for example, to write the protection value in eadrh, the two following commands need to be executed: ? command i with data = value of protection byte 0x3fff. ? command f with data = 0xc7. following this protocol, the protection can be written to the flash using the same sequence as mentioned in the enabling flash protection by code section. when the part is reset, the protection is effective. notes on flash protection the flash protection scheme is disabled by default so that none of the pages of the flash are protected from reading or writing/ erasing. the last page must be read and write/erase protected for the protection scheme to work. to activate the protection settings, the ADE7566/ade7569/ ade7166/ade7169 must be reset after configuring the protection. after configuring protection on the last page and resetting the part, protections that have been enabled can only be removed by mass erasing the flash memory. the protection bits are read and erase protected by enabling read and write/erase protection on the last page, but the protection bits are never truly write protected. protection bits can be modified from a 1 to a 0, even after the last page has been protected. in this way, more protection can be added but none can be removed. the protection scheme is intended to protect the end system. pro- tection should be disabled while developing and emulating code. flash memory timing typical program and erase times for the flash memory are shown in table 101 . table 101. flash memory program and and erase times command bytes affected flash memory timing write byte 1 byte 30 s erase page 512 bytes 20 ms erase all 16 kb 200 ms read byte 1 byte 100 ns erase page and write byte 512 bytes 21 ms verify byte 1 byte 100 ns note that the core microcontroller operation is idled until the requested flash memory operation is complete. in practice, this means that even though the flash operation is typically initiated with a two-machine-cycle mov instruction to write to the flash control sfr (econ, 0xb9), the next instruction is not executed until the flash/ee operation is complete. this means that the core cannot respond to interrupt requests until the flash/ee operation is complete, although the core peripheral functions, such as counters and timers, continue to count as configured throughout this period. in-circuit programming serial downloading the ADE7566/ade7569/ade7166/ade7169 facilitate code download via the standard uart serial port. the parts enter serial download mode after a reset or a power cycle if the sden pin is pulled low through an external 1 k resistor. when in serial download mode, the hidden embedded download kernel executes. this allows the user to download code to the full 16 kb of flash memory while the device is in-circuit in its target application hardware. protection configured in the last page of the ADE7566/ade7569/ ade7166/ade7169 affects whether flash memory can be accessed in serial download mode. read protected pages cannot be read. write/erase protected pages cannot be written or erased.
ADE7566/ade7569/ade7166/ade7169 rev. a | page 109 of 144 timers each ADE7566/ade7569/ade7166/ade7169 has three 16-bit timer/counters: timer/counter 0, timer/counter 1, and timer/ counter 2. the timer/counter hardware is included on-chip to relieve the processor core of overhead inherent in implementing timer/counter functionality in software. each timer/counter con- sists of two 8-bit registers: thx and tlx (x = 0, 1, or 2). all three timers can be configured to operate as timers or as event counters. when functioning as a timer, the tlx register is incremented every machine cycle. thus, users can think of it as counting machine cycles. because a machine cycle on a single cycle core consists of one core clock period, the maximum count rate is the core clock frequency. when functioning as a counter, the tlx register is incremented by a 1-to-0 transition at its corresponding external input pin: t0, t1, or t2. when the samples show a high in one cycle and a low in the next cycle, the count is incremented. because it takes two machine cycles (two core clock periods) to recognize a 1-to-0 transition, the maximum count rate is half the core clock frequency. there are no restrictions on the duty cycle of the external input signal, but to ensure that a given level is sampled at least once before it changes, it must be held for a minimum of one full machine cycle. user configuration and control of all timer operating modes is achieved via the sfrs in table 102 . table 102. timer sfrs sfr address bit addressable description tcon 0x88 yes timer/counter 0 and timer/counter 1 control (see table 104 ). tmod 0x89 no timer/counter 0 and timer./counter 1 mode (see table 103 ). tl0 0x8a no timer 0 low byte (see table 107 ). tl1 0x8b no timer 1 low byte (see table 109 ). th0 0x8c no timer 0 high byte (see table 106 ). th1 0x8d no timer 1 high byte (see table 108 ). t2con 0xc8 yes timer/counter 2 control (see table 105 ). rcap2l 0xca no timer 2 reload/capture low byte (see table 113 ). rcap2h 0xcb no timer 2 reload/capture high byte (see table 112 ). tl2 0xcc no timer 2 low byte ( table 111 ). th2 0xcd no timer 2 high byte (see table 110 ). timer registers table 103. timer/counter 0 and timer/counter 1 mode sfr (tmod, 0x89) bit mnemonic default description 7 gate1 0 timer 1 gating control. set by software to enable timer/counter 1 only when the int1 pin is high and the tr1 control is set. cleared by software to enab le timer 1 whenever the tr1control bit is set. 6 c/ t1 0 timer 1 timer or counter select bit. set by software to select counter operation (input from t1 pin). cleared by software to select the timer ope ration (input from internal system clock). timer 1 mode select bits. t1/m[1:0] result 00 th1 operates as an 8-bit timer/counte r. tl1 serves as 5-bit prescaler. 01 16-bit timer/counter. th1 and tl1 are cascaded; there is no prescaler. 10 8-bit autoreload timer/counter. th1 holds a value to reload into tl1 each time it overflows. 5 to 4 t1/m1, t1/m0 00 11 timer/counter 1 stopped. 3 gate0 0 timer 0 gating control. set by software to enable timer/counter 0 only when the int0 pin is high and the tr0 control bit is set. cleared by software to enable timer 0 whenever the tr0 control bit is set. 2 c/ t0 0 timer 0 timer or counter select bit. set by software to the select counter operation (input from t0 pin). cleared by software to the select timer operation (input from internal system clock). timer 0 mode select bits. t0/m[1:0] result 00 th0 operates as an 8-bit timer/counter. tl0 serves as a 5-bit prescaler. 01 16-bit timer/counter. th0 and tl0 are cascaded; there is no prescaler. 10 8-bit autoreload timer/counter. th0 holds a value to reload into tl0 each time it overflows. 1 to 0 t0/m1, t0/m0 00 11 tl0 is an 8-bit timer/counter controlled by the standard timer 0 control bits. th0 is an 8-bit timer only, controlled by timer 1 control bits.
ADE7566/ade7569/ade7166/ade7169 rev. a | page 110 of 144 table 104. timer/counter 0 and timer/counter 1 control sfr (tcon, 0x88) bit address mnemonic default description 7 0x8f tf1 0 timer 1 overflow flag. set by hardware on a timer/counter 1 overflow. cleared by hardware when the program counter (pc) vectors to the interrupt service routine. 6 0x8e tr1 0 timer 1 run control bit. set by the user to turn on timer/counter 1. cleared by the user to turn off timer/counter 1. 5 0x8d tf0 0 timer 0 overflow flag. set by hardware on a timer/counter 0 overflow. cleared by hardware when the pc vectors to the interrupt service routine. 4 0x8c tr0 0 timer 0 run control bit. set by the user to turn on timer/counter 0. cleared by the user to turn off timer/counter 0. 3 0x8b ie1 1 0 external interrupt 1 ( int1 ) flag. set by hardware by a falling edge or by a zero level applied to the external interrupt pin, int1 , depending on the state of bit it1. cleared by hardware when the pc vectors to the interrupt service routine only if the interrupt was transition activated. if level activated, the external requesting sour ce controls the request flag rather than the on-chip hardware. 2 0x8a it1 1 0 external interrupt 1 (ie1) trigger type. set by softwa re to specify edge sensitive detection, that is, 1- to-0 transition. cleared by software to specify level sensitive detection, that is, zero level. 1 0x89 ie0 1 0 external interrupt 0 ( int0 ) flag. set by hardware by a falling edge or by a zero level being applied to the external interrupt pin, int0 , depending on the state of bit it0. cleared by hardware when the pc vectors to the interrupt service routine only if the interrupt was transition activated. if level activated, the external requesting source controls the request flag rather than the on-chip hardware. 0 0x88 it0 1 0 external interrupt 0 (ie0) trigger type. set by software to specify edge sensitive detection, that is, 1-to- 0 transition. cleared by software to specify level sensitive detection, that is, zero level. 1 these bits are not used to control timer/counter 0 and timer/counter 1 but are instead used to control and monitor the externa l int0 and int1 interrupt pins. table 105. timer/counter 2 control sfr (t2con, 0xc8) bit address mnemonic default description 7 0xcf tf2 0 timer 2 overflow flag. set by hardware on a t imer 2 overflow. tf2 cannot be set when either rclk = 1 or tclk = 1. cleared by user software. 6 0xce exf2 0 timer 2 external flag. set by hardware when either a capture or reload is caused by a negative transition on t2ex pin and exen2 = 1. cleared by user software. 5 0xcd rclk 0 receive clock enable bit. set by the user to enable the serial port to use timer 2 overflow pulses for its receive clock in serial port mode 1 and seri al port mode 3. cleared by the user to enable timer 1 overflow to be used for the receive clock. 4 0xcc tclk 0 transmit clock enable bit. set by the user to enable the serial port to use timer 2 overflow pulses for its transmit clock in serial port mode 1 and serial port mode 3. cleared by the user to enable timer 1 overflow to be used for the transmit clock. 3 0xcb exen2 0 timer 2 external enable flag. set by the user to enable a capture or reload to occur as a result of a negative transition on t2ex if timer 2 is not be ing used to clock the seri al port. cleared by the user for timer 2 to ignore events at t2ex. 2 0xca tr2 0 timer 2 start/stop control bit. set by the user to start timer 2. cleared by the user to stop timer 2. 1 0xc9 c/ t2 0 timer 2 timer or counter function select bit. set by the user to select the counter function (input from external t2 pin). cleared by the user to se lect the timer function (input from on-chip core clock). 0 0xc8 cap2 0 timer 2 capture/reload select bit. set by the user to enable captures on negative transitions at t2ex if exen2 = 1. cleared by the user to enable autoreloads with timer 2 overflows or negative transitions at t2ex when exen2 = 1. when either rclk = 1 or tclk = 1, this bit is ignored and the timer is forced to autoreload on timer 2 overflow.
ADE7566/ade7569/ade7166/ade7169 rev. a | page 111 of 144 mode 0 (13-bit timer/counter) table 106. timer 0 high byte sfr (th0, 0x8c) bit mnemonic default description mode 0 configures an 8-bit timer/counter. figure 95 shows mode 0 operation. note that the divide-by-12 prescaler is not present on the single cycle core. 7 to 0 th0 0 timer 0 data high byte. table 107. timer 0 low byte sfr (tl0, 0x8a) control tr0 tf0 tl0 (5 bits) th0 (8 bits) interrupt 06353-071 p0.6/t0 gate i nt0 f core c/t0 = 0 c/t0 = 1 bit mnemonic default description 7 to 0 tl0 0 timer 0 data low byte. table 108. timer 1 high byte sfr (th1, 0x8d) bit mnemonic default description 7 to 0 th1 0 timer 1 data high byte. table 109. timer 1 low byte sfr (tl1, 0x8b) bit mnemonic default description 7 to 0 tl1 0 timer 1 data low byte. figure 95. timer/counter 0, mode 0 in this mode, the timer register is configured as a 13-bit register. as the count rolls over from all 1s to all 0s, it sets the timer overflow flag, tf0. tf0 can then be used to request an interrupt. the counted input is enabled to the timer when tr0 = 1 and either gate0 = 0 or table 110. timer 2 high byte sfr (th2, 0xcd) bit mnemonic default description 7 to 0 th2 0 timer 2 data high byte. table 111. timer 2 low byte sfr (tl2, 0xcc) int0 = 1. setting gate0 = 1 allows the timer to be controlled by external input bit mnemonic default description int0 to facilitate pulse width measurements. tr0 is a control bit in the timer/counter 0 and timer/counter 1 control sfr (tcon, 0x88); the gate bit is in timer/counter 0 and timer/counter 1 mode sfr (tmod, 0x89). the 13-bit register consists of all 8 bits of timer 0 high byte sfr (th0, 0x8c) and the lower 5 bits of timer 0 low byte sfr (tl0, 0x8a). the upper three bits of tl0 sfr are indeterminate and should be ignored. setting the run flag (tr0) does not clear the registers. 7 to 0 tl2 0 timer 2 data low byte. table 112. timer 2 reload/capture high byte sfr (racp2h, 0xcb) bit mnemonic default description 7 to 0 th2 0 timer 2 reload/ capture high byte. table 113. timer 2 reload/capture low byte sfr (racp2l, 0xca) mode 1 (16-bit timer/counter) bit mnemonic default description mode 1 is the same as mode 0 except that the mode 1 timer register runs with all 16 bits. mode 1 is shown in 7 to 0 tl2 0 timer 2 reload/ capture low byte. figure 96 . control tr0 tf0 tl0 (8 bits) th0 (8 bits) interrupt 0 06353-072 p0.6/t0 gate int c/t0 = 0 c/t0 = 1 f core timer 0 and timer 1 timer/counter 0 and timer/counter 1 data registers each timer consists of two 8-bit registers. they are timer 0 high byte sfr (th0, 0x8c), timer 0 low byte sfr (tl0, 0x8a), timer 1 high byte sfr (th1, 0x8d), and timer 1 low byte sfr (tl1, 0x8b) these can be used as independent registers or combined into a single 16-bit register, depending on the timer mode configuration (see table 106 to table 109 ). timer/counter 0 and timer/counter 1 operating modes figure 96. timer/counter 0, mode 1 this section describes the operating modes for timer/counter 0 and timer/counter 1. unless otherwise noted, these modes of operation are the same for both timer 0 and timer 1.
ADE7566/ade7569/ade7166/ade7169 rev. a | page 112 of 144 mode 2 (8-bit timer/counter with autoreload) timer 2 timer/counter 2 data registers mode 2 configures the timer register as an 8-bit counter (tl0) with automatic reload as shown in figure 97 . overflow from tl0 not only sets tf0 but also reloads tl0 with the contents of th0, which is preset by software. the reload leaves th0 unchanged. timer/counter 2 also has two pairs of 8-bit data registers associated with it: timer 2 high byte sfr (th2, 0xcd), timer 2 low byte sfr (tl2, 0xcc), timer 2 reload/capture high byte sfr (racp2h, 0xcb), and timer 2 reload/capture low byte sfr (racp2l, 0xca). these are used as both timer data registers and as timer capture/reload registers (see control tf0 tl0 (8 bits) interrupt reload th0 (8 bits) tr0 06353-073 p0.6/t0 gate int0 c/t = 0 c/t = 1 f core table 110 to table 113 ). timer/counter 2 operating modes the following sections describe the operating modes for timer/counter 2. the operating modes are selected by bits in the timer/counter 2 control sfr (t2con, 0xc8), as shown in table 105 and table 114 . figure 97. timer/counter 0, mode 2 table 114. t2con operating modes mode 3 (two 8-bit timer/counters) rclk (or) tclk cap2 tr2 mode 0 0 1 16-bit autoreload mode 3 has different effects on timer 0 and timer 1. timer 1 in mode 3 simply holds its count. the effect is the same as setting tr1 = 0. timer 0 in mode 3 establishes tl0 and th0 as two separate counters. this configuration is shown in 0 1 1 16-bit capture 1 x 1 baud rate x x 0 off figure 98 . tl0 uses the timer 0 control bits, c/ t , gate0 (see table 103 ), tr0, tf0 (see 16-bit autoreload mode int0 table 104 ), and . th0 is locked into a timer function (counting machine cycles) and takes over the use of tr1 and tf1 from timer 1. therefore, th0 controls the timer 1 interrupt. mode 3 is provided for applications requiring an extra 8-bit timer or counter. autoreload mode has two options that are selected by bit exen2 in timer/counter 2 control sfr (t2con, 0xc8). if exen2 = 0 when timer 2 rolls over, it not only sets tf2 but also causes the timer 2 registers to be reloaded with the 16-bit value in both the timer 2 reload/capture high byte sfr (racp2h, 0xcb) and timer 2 reload/capture low byte sfr (racp2l, 0xca) registers, which are preset by software. if exen2 = 1, timer 2 performs the same events as when exen2 = 0 but adds a 1-to-0 transition at external input t2ex, which triggers the 16-bit reload and sets exf2. autoreload mode is shown in when timer 0 is in mode 3, timer 1 can be turned on and off by switching it out of and into its own mode 3, or it can be used by the serial interface as a baud rate generator. in fact, timer1 can be used in any application not requiring an interrupt from timer 1 itself. figure 99 . control core clk/12 tf0 tl0 (8 bits) interrupt p0.6/t0 gate tr0 tf1 th0 (8 bits) interrupt f core /12 tr1 0 in t c/t = 0 c/t = 1 06353-074 f core 16-bit capture mode capture mode has two options that are selected by bit exen2 in timer/counter 2 control sfr (t2con, 0xc8). if exen2 = 0, timer 2 is a 16-bit timer or counter that, upon overflowing, sets bit tf2, the timer 2 overflow bit, which can be used to generate an interrupt. if exen2 = 1, timer 2 performs the same events as when exen2 = 0 but adds a l-to-0 transition on external input t2e, which causes the current value in the timer 2 registers, tl2 and th2, to be captured into the rcap2l and rcap2h registers, respectively. in addition, the transition at t2ex causes bit exf2 in t2con to be set, and exf2, like tf2, can generate an interrupt. capture mode is shown in figure 100 . the baud rate generator mode is selected by rclk = 1 and/or tclk = 1. in either case, if timer 2 is used to generate the baud rate, the tf2 interrupt flag does not occur. therefore, timer 2 interrupts do not occur and do not have to be disabled. in this mode, the exf2 flag can, however, still cause interrupts that can be used as a third external interrupt. baud rate generation is described as part of the uart serial port operation in the figure 98. timer/counter 0, mode 3 uart serial interface section.
ADE7566/ade7569/ade7166/ade7169 rev. a | page 113 of 144 tr2 control tl2 (8 bits) th2 (8 bits) reload tf2 exf2 timer interrupt exen2 control transition detector rcap2l rcap2h c/ t2 = 0 06353-075 p1.4/t2 p1.3/ t2ex c/ t2 = 1 f core figure 99. timer/counter 2, 16-bit autoreload mode tf2 p1.4/t2 p1.3/ t2ex tr2 control tl2 (8 bits) th2 (8 bits) capture exf2 timer interrupt exen2 control transition detector rcap2l rcap2h c/ t2 = 1 c/ t2 = 0 06353-076 f core figure 100. timer/counter 2, 16-bit capture mode
ADE7566/ade7569/ade7166/ade7169 rev. a | page 114 of 144 pll the ADE7566/ade7569/ade7166/ade7169 are intended for use with a 32.768 khz watch crystal. a pll locks onto a multiple of this frequency to provide a stable 4.096 mhz clock for the system. the core can operate at this frequency or at binary submultiples of it to allow power savings when maximum core performance is not required. the default core clock is the pll clock divided by 4 or 1.024 mhz. the ade energy measurement clock is derived from the pll clock and is maintained at 4.096 mhz/5 mhz, 819.2 khz across all cd settings. the pll is controlled by the cd[2:0] bits in the power control sfr (powcon, 0xc5). to protect erroneous changes to the powcon srf, a key is required to modify the register. first, the key sfr (kyreg, 0xc1) is written with the key, 0xa7, and then a new value is written to the powcon sfr. if the pll loses lock, the mcu is reset and the pll_flt bit is set in the peripheral configuration sfr (periph, 0xf4). set the pllack bit in the start adc measurement sfr (adcgo, 0xd8) to acknowledge the pll fault, clearing the pll_flt bit. pll registers table 115. power control sfr (powcon, 0xc5) bit mnemonic default description 7 reserved 1 reserved. 6 meter_off 0 set this bit to turn off the modulators and energy metering dsp circuitry to reduce power if metering functions are not needed in psm0. 5 reserved 0 this bit should be kept at 0 for proper operation. 4 coreoff 0 set this bit to shut down th e core if in the psm1 operating mode. 3 reserved reserved. controls the core clock frequency (f core ). f core = 4.096 mhz/2 cd . cd[2:0] result (f core in mhz) 000 4.096 001 2.048 010 1.024 011 0.512 100 0.256 101 0.128 110 0.064 2 to 0 cd[2:0] 010 111 0.032 writing to the power control sfr (powcon, 0xc5) note that writing data to the powcon sfr involves writing 0xa7 into the key sfr (kyreg, 0xc1) followed by a write to the powcon sfr. table 116. key sfr (kyreg, 0xc1) bit mnemonic default description 7 to 0 kyreg 0 write 0xa7 to the kyreg sfr before writing to the powcon sfr to unlock it. write 0xea to the kyreg sfr before writing to the intpr, hthsec, sec, min, or hour timekeeping registers to unlock it.
ADE7566/ade7569/ade7166/ade7169 rev. a | page 115 of 144 table 117. peripheral configuration sfr (periph, 0xf4) bit mnemonic default description 7 rxflag 0 if set, indicates that a rx edge event triggered wake-up from psm2. 6 vswsource 1 indicates the power supply that is connected internally to v swout . if set, v swout = v dd . if cleared, v swout = v bat . 5 vdd_ok 1 if set, indicates that v dd power supply is ok for operation. 4 pll_flt 0 if set, indicates that pll is not locked. 3 ref_bat_en 0 if set, the internal voltage reference is enabled in psm2 mode. this bit should be set if the lcd is on in psm2 mode. 2 reserved 0 this bit should be kept to zero. controls the function of the p1.0/rxd pin. rxprog [1:0] result 00 gpio 01 rx with wake-up disabled 1 to 0 rxprog[1:0] 00 11 rx with wake-up enabled table 118. start adc measurement sfr (adcgo, 0xd8) bit address mnemonic default description 7 0xdf pll_ftl_ack 0 set this bit to clear the pll fault bit, pll_flt in the periph register. a pll fault is generated if a reset was caused because the pll lost lock. 6 to 3 0xde to 0xdb reserved 0 reserved. 2 0xda vdcin_adc_go 0 set this bit to initiate an external voltage measurement. this bit is cleared when the measurement request is received by the adc. 1 0xd9 temp_adc_go 0 set this bit to initiate a temperature measurement. this bi t is cleared when the measurement request is received by the adc. 0 0xd8 batt_adc_go 0 set this bit to initiate a battery meas urement. this bit is cleared when the measurement request is received by the adc.
ADE7566/ade7569/ade7166/ade7169 rev. a | page 116 of 144 real-time clock the ADE7566/ade7569/ade7166/ade7169 have an embedded real-time clock (rtc) as shown in rtc registers figure 101 . the external 32.768 khz crystal is used as the clock source for the rtc. calibration is provided to compensate the nominal crystal frequency and for variations in the external crystal frequency over temperature. by default, the rtc is maintained active in all power saving modes. the rtc counters retain their values through watchdog resets and external resets. they are only reset during a power-on reset. note that all the real-time clock sfrs are not bit addressable. table 119. real-time clock sfr sfr address description timecon 0xa1 rtc configuration (see table 120 ). hthsec 0xa2 hundredths of a second counter (see table 121 ). 8-bit prescaler second counter sec minute counter min hour counter hour iten alarm event 8-bit interval counter intval sfr interval timebase selection mux rtcen 32.768khz crystal its1 its0 equal? calibration rtccomp tempcal midnight event calibrated 32.768khz 06353-077 hundredths counter hthsec figure 101. rtc implementation sec 0xa3 seconds counter (see table 122 ). min 0xa4 minutes counter (see table 123 ). hour 0xa5 hours counter (see table 124 ). intval 0xa6 alarm interval (see table 125 ). rtccomp 0xf6 rtc nominal compensation (see table 126 ). tempcal 0xf7 rtc temperature compensation (see table 127 ). protecting the rtc from runaway code to protect the rtc from runaway code, a key must be written to the kyreg register to obtain write access to the interrupt pins configuration sfr (intpr, 0xff), hundredths of a second counter sfr (hthsec, 0xa2), seconds counter sfr (sec, 0xa3), minutes counter sfr (min, 0xa4), and hours counter sfr (hour, 0xa5). kyreg should be set to 0xea to unlock it and reset it to zero after a timekeeping register is written to. the rtc registers can be written using the following 8052 assembly code: mov kyreg,#0eah mov intpr,#080h
ADE7566/ade7569/ade7166/ade7169 rev. a | page 117 of 144 table 120. rtc configuration sfr (timecon, 0xa1) bit mnemonic default description 7 midnight 0 midnight flag. this bit is set when the rtc rolls over to 00:00:00:00. it can be cleared by the user to indicate that the midnight event has been serviced . in twenty-four hour mode, the midnight flag is raised once a day at midnight. when this interrup t is used for wake-up from psm2 to psm1, the rtc interrupt must be serviced and the flag cleared to be allowed to enter psm2. twenty-four hour mode. this bit is retained during a wa tchdog reset or an external reset. it is reset after a power-on reset (por). tfh result 0 256-hour mode. the hour register rolls over from 255 to 0. 6 tfh 0 1 24-hour mode. the hour register rolls over from 23 to 0. interval timer timebase selection. its[1:0] result (time base) 00 1/128 sec. 01 second. 10 minute. 5 to 4 its[1:0] 0 11 hour. interval timer 1 alarm. sit result 0 the alarm flag is set after intval counts and then another interval count starts. 3 sit 0 1 the alarm flag is set after one time interval. 2 alarm 0 interval timer alarm flag. this bit is set when the configured time interval has elapsed. it can be cleared by the user to indicate that the alarm event has been serviced. this bit cannot be set to 1 by user code. interval timer enable. iten result 0 the interval timer is disabled. the 8-bit interval timer counter is reset. 1 iten 0 1 set this bit to enable the interval timer. th e rtcen bit must also be set to enable the interval timer. 0 reserved 1 this bit must be left set for proper operation. table 121. hundredths of a second counter sfr (hthsec, 0xa2) bit mnemonic default description 7 to 0 hthsec 0 this counter updates every 1/128 second, referenced from the calibrated 32.768 khz clock. it overflows from 127 to 00, incrementing the seconds counter (sec ). this register is retained during a watchdog reset or an external reset. it is reset after a por. table 122. seconds counter sfr (sec, 0xa3) bit mnemonic default description 7 to 0 sec 0 this counter updates every second, referenced from the calibrated 32.768 khz clock. it overflows from 59 to 00, incrementing the minutes counter (min). this regi ster is retained during a watchdog reset or an external reset. it is reset after a por. table 123. minutes counter sfr (min, 0xa4) bit mnemonic default description 7 to 0 min 0 this counter updates every minute, referenced from the calibrated 32.768 khz clock. it overflows from 59 to 00, incrementing the hours counter, hour. this regi ster is retained during a watchdog reset or an external reset. it is reset after a por. table 124. hours counter sfr (hour, 0xa5) bit mnemonic default description 7 to 0 hour 0 this counter updates every hour, referenced from the calibrated 32.768 khz clock. if the tfh bit in the rtc configuration sfr (timecon, 0xa1) is set, the hour sfr overflows from 23 to 00, setting the midnight bit and creating a pending rtc interrupt. if the tfh bit is cleared, the hour sfr overflows from 255 to 00, setting the midnight bit and creating a pending rtc interrupt. this register is retained during a watchdog reset or an external reset. it is reset after a por.
ADE7566/ade7569/ade7166/ade7169 rev. a | page 118 of 144 table 125. alarm interval sfr (intval, 0xa6) bit mnemonic default description 7 to 0 intval 0 the interval timer counts according to the time base es tablished in the its[1:0] bits of the rtc configuration sfr (timecon, 0xa1). once the number of counts is equal to intval, the alarm flag is set and a pending rtc interrupt is created. note that the interval counter is eight bits. therefore, it can count up to 255 seconds, for example. table 126. rtc nominal compensation sfr (rtccomp, 0xf6) bit mnemonic default description 7 to 0 rtccomp 0 the rtccomp sfr holds the nominal rtc compensation va lue at 25c. this register is retained during a watchdog reset or an external reset. it is reset after a por. table 127. rtc temperature compensation sfr (tempcal, 0xf7) bit mnemonic default description 7 to 0 tempcal 0 the tempcal sfr is adjusted based on the temperature read in the tempadc to calibrate the rtc over temperature. this allows the external crystal shift to be compensated over temperature. this register is retained during a watchdog reset or an external reset. it is reset after a por. table 128. interrupt pins configuration sfr (intpr, 0xff) bit mnemonic default description 7 rtccal 0 controls the rtc calibration output. when set, the rtc calibration frequency selected by fsel[1:0] is output on the p0.2/cf1/rtccal pin. sets rtc calibration output freq uency and calibration window. fsel[1:0] result (calibration window, frequency) 0 0 30.5 sec, 1 hz 0 1 30.5 sec, 512 hz 1 0 0.244 sec, 500 hz 6 to 5 fsel[1:0] 1 1 0.244 sec, 16.384 khz 4 reserved controls the function of int1 . int1prg[2:0] result x 0 0 gpio x 0 1 bctrl 0 1 x int1 input disabled 3 to 1 int1prg[2:0] 000 1 1 x int1 input enabled controls the function of int0 . int0prg result 0 int0 input disabled 0 int0prg 0 1 int0 input enabled table 129. key sfr (kyreg, 0xc1) bit mnemonic default description 7 to 0 kyreg 0 write 0xa7 to the this sfr before writing to the powcon sfr, which unlocks kyreg. write 0xea to the this sfr before writing to the intpr, hthsec, sec, min, or hour timekeeping registers to unlock kyreg.
ADE7566/ade7569/ade7166/ade7169 rev. a | page 119 of 144 read and write operations writing to the rtc registers the rtc circuitry runs off a 32.768 khz clock. the timekeeping registers, hundredths of a second counter sfr (hthsec, 0xa2), seconds counter sfr (sec, 0xa3), minutes counter sfr (min, 0xa4), and hours counter sfr (hour, 0xa5), are updated with a 32.768 khz clock. however, the rtc configuration sfr (timecon, 0xa1) and alarm interval sfr (intval, 0xa6) are updated with a 128 hz clock. it takes up to two 128 hz clock cycles from when the mcu writes to the timecon sfr or intval sfr until there is a successful update in the rtc. to protect the rtc timekeeping registers from runaway code, a key must be written to the key sfr (kyreg, 0xc1), which is described in table 116 , to obtain write access to the hthsec, sec, min and hour sfrs. kyreg should be set to 0xea to unlock the timekeeping registers and reset to 0 after a timekeeping register is written to. the rtc registers can be written to using the following 8052 assembly code: mov rtckey,#0eah call updatertc ? updatertc: mov kyreg,rtckey mov sec,#30 mov kyreg,rtckey mov min,#05 mov kyreg,rtckey mov hour,#04 mov kyreg,#00h ret reading the rtc counter sfrs the rtc cannot be stopped to read the current time because stopping the rtc introduces an error in its timekeeping. therefore, the rtc is read on the fly, and the counter registers must be checked for overflow. this can be accomplished through the following 8052 assembly code: readagain: mov r0,hthsec ; using bank 0 mov r1,sec mov r2,min mov r3,hour mov a,hthsec cjne a, 00h, readagain ; 00h is r0 in bank 0 rtc modes the rtc can be configured in a 24-hour mode or a 256-hour mode. a midnight event is generated when the rtc hour counter rolls over from 23 to 0 or 255 to 0, depending on whether the tfh bit is set in the rtc configuration sfr (timecon, 0xa1). the midnight event sets the midnight flag in the timecon sfr, and a pending rtc interrupt is created. the rtc midnight event wakes the 8052 mcu core if the mcu is asleep in psm2 when the midnight event occurs. in the 24-hour mode, the midnight event is generated once a day at midnight. the 24-hour mode is useful for updating a software calendar to keep track of the current day. the 256-hour mode results in power savings during extended operation in psm2 because the mcu core wakes up less frequently. rtc interrupts the rtc midnight interrupt and alarm interrupt are enabled by setting the eti bit in the interrupt enable and priority 2 sfr (ieip2, 0xa9). when a midnight or alarm event occurs, a pending rtc interrupt is generated. if the rtc interrupt is enabled, the program vectors to the rtc interrupt address and the pending interrupt is cleared. if the rtc interrupt is disabled, the rtc interrupt remains pending until the rtc interrupt is enabled. the program then vectors to the rtc interrupt address. the midnight flag and alarm flag are set when the midnight event and alarm event occur, respectively. the user should manage these flags to keep track of which event caused an rtc interrupt by servicing the event and clearing the appropriate flag in the rtc interrupt servicing routine. note that if the ADE7566/ade7569/ade7166/ade7169 are awakened by an rtc event, either by the midnight event or alarm event, the pending rtc interrupt must be serviced before the device can go back to sleep again. the ADE7566/ ade7569/ade7166/ade7169 keep waking up until this interrupt has been serviced. interval timer alarm the rtc can be used as an interval timer. when the interval timer is enabled by setting the iten bit in the rtc configuration sfr (timecon, 0xa1), the interval timer clock source selected by the its1 and its0 bits is passed through an 8-bit counter. this counter increments on every interval timer clock pulse until it is equal to the value in the alarm interval sfr (intval, 0xa6). then, an alarm event is generated, setting the alarm flag and creating a pending rtc interrupt. if the sit bit in the rtc configuration sfr (timecon, 0xa1) is cleared, the 8-bit counter is also cleared and starts counting again. if the sit bit is set, the 8-bit counter is held in reset after the alarm occurs.
ADE7566/ade7569/ade7166/ade7169 rev. a | page 120 of 144 take care when changing the interval timer time base. the recommended procedure is as follows: 1. if the alarm interval sfr (intval, 0xa6) is going to be modified, write to this register first. then, wait for one 128 hz clock cycle to synchronize with the rtc, 64,000 cycles at a 4.096 mhz instruction cycle clock. 2. disable the interval timer by clearing the iten bit in the rtc configuration sfr (timecon, 0xa1). then, wait for one 128 hz clock cycle to synchronize with the rtc, 64,000 cycles at a 4.096 mhz instruction cycle clock. 3. read the timecon sfr to ensure that the iten bit is clear. if it is not, wait for another 128 hz clock cycle. 4. set the time-base bits (its[1:0]) in the timecon sfr to configure the interval. wait for a 128 hz clock cycle for this change to take effect. the rtc alarm event wakes the 8052 mcu core if the mcu is in psm2 when the alarm event occurs. rtc calibration the rtc provides registers to calibrate the nominal external crystal frequency and its variation over temperature. a frequency error up to 248 ppm can be calibrated out by the rtc circuitry, which adds or subtracts pulses from the external crystal signal. the nominal crystal frequency should be calibrated with the rtc nominal compensation register so that the clock going into the rtc is precisely 32.768 khz at 25c. the rtc temperature compensation sfr (tempcal, 0xf7) is used to compensate for the external crystal drift over temperature by adding or subtracting additional pulses based on temperature. the lsb of each rtc compensation register represents a 2 ppm frequency error. the rtc compensation circuitry adds the rtc temperature compensation sfr (tempcal, 0xf7) and the rtc nominal compensation sfr (rtccomp, 0xf6) to determine how much compensation is required. note that the sum of these two registers is limited to 248 ppm. calibration flow a rtc calibration pulse output is provided on the p0.2/cf1/ rtccal pin. enable the rtc output by setting the rtccal bit in the interrupt pins configuration sfr (intpr, 0xff). the rtc calibration is accurate to within 2 ppm over a 30.5 second window in all operational modes: psm0, psm1, and psm2. two output frequencies are offered for the normal rtc mode: 1 hz with fsel[1:0] = 00 and 512 hz with fsel[1:0] = 01 in the interrupt pins configuration sfr (intpr, 0xff). a shorter window of 0.244 seconds is offered for fast calibration during psm0 or psm1. two output frequencies are offered for this rtc calibration output mode: 500 hz with fsel[1:0] = 10 and 16.384 khz with fsel[1:0] = 11 in the intpr sfr. note that for the 0.244 second calibration window, the rtc is clocked 125 times faster than in normal mode, resulting in timekeeping registers that represent seconds/125, minutes/125, and hours/125 instead of seconds, minutes, and hours. therefore, this mode should be used for calibration only. table 130. rtc calibration options option fsel[1:0] calibration window (sec) f rtccal (hz) normal mode 0 00 30.5 1 normal mode 1 01 30.5 512 calibration mode 0 10 0.244 500 calibration mode 1 11 0.244 16,384 when no rtc compensation is applied, that is, when rtc nominal compensation sfr (rtccomp, 0xf6) and rtc temperature compensation sfr (tempcal, 0xf7) are equal to 0, the nominal compensation required to account for the error in the external crystal can be determined. in this case, it is not necessary to wait for an entire calibration window to determine the error in the pulse output. calculating at the error in frequency between two consecutive pulses on the p0.2/cf1/rtccal pin is enough. the value to write to the rtc nominal compensation sfr (rtccomp, 0xf6) is calculated from the % error or seconds per day error on the frequency output. each lsb of the rtccomp sfr represents 2 ppm of correction where 1 second/day error is equal to 11.57 ppm. )(%5000 error rtccomp = ) ( 57.112 1 error sec/day rtccomp = during calibration, user software writes the rtc with the current time. refer to the read and write operations section for more information on how to read and write the rtc timekeeping registers.
ADE7566/ade7569/ade7166/ade7169 rev. a | page 121 of 144 uart serial interface the ADE7566/ade7569/ade7166/ade7169 uart can be configured in one of four modes. ? shift register with baud rate fixed at f core /12 ? 8-bit uart with variable baud rate ? 9-bit uart with baud rate fixed at f core /64 or f core /32 ? 9-bit uart with variable baud rate variable baud rates are defined by using an internal timer to generate any rate between 300 baud/second and 115,200 baud/second. the uart serial interface provided in the ADE7566/ade7569/ ade7166/ade7169 is a full-duplex serial interface. it is also receive buffered by storing the first received byte in a receive buffer until the reception of the second byte is complete. the physical interface to the uart is provided via the rxd (p1.0) and txd (p1.1) pins, while the firmware interface is through the sfrs presented in table 131 . both the serial port receive and transmit registers are accessed through the serial port buffer sfr (sbuf, 0x99). writing to sbuf loads the transmit register, and reading sbuf accesses a physically separate receive register. an enhanced uart mode is offered by using the uart timer and by providing enhanced frame error, break error, and overwrite error detection. this mode is enabled by setting the exten bit in the configuration sfr (cfg, 0xaf) (see the uart additional features section). the enhanced serial baud rate control sfr (sbaudt, 0x9e) and uart timer fractional divider sfr (sbaudf, 0x9d) are used to configure the uart timer and to indicate the enhanced uart errors. uart registers table 131. serial port sfrs sfr address bit addressable description scon 0x98 yes serial communications control register (see table 132 ). sbuf 0x99 no serial port buffer (see table 133 ). sbaudt 0x9e no enhanced serial baud rate control (see table 134 ). sbaudf 0x9d no uart timer fractional divider (see table 135 ). table 132. serial communications control re gister bit description sfr (scon, 0x98) bit address mnemonic default description uart serial mode select bits. these bits select the serial port operating mode. sm[0:1] result (selected operating mode) 00 mode 0, shift register, fixed baud rate (f core /12). 01 mode 1, 8-bit uart, variable baud rate. 10 mode 2, 9-bit uart, fixed baud rate (f core /32) or (f core /16). 7 to 6 0x9f, 0x9e sm0, sm1 00 11 mode 3, 9-bit uart, variable baud rate. 5 0x9d sm2 0 multiprocessor communication enable bit. enables multiprocessor communication in mode 2 and mode 3, and framing error detection in mode 1. in mode 0, sm2 should be cleared. in mode 1, if sm2 is set, ri is not activated if a valid stop bit was not received. if sm2 is cleared, ri is set as soon as the byte of data is received. in mode 2 or mode 3, if sm2 is set, ri is not ac tivated if the received nint h data bit in rb8 is 0. if sm2 is cleared, ri is set as soon as the byte of data is received. 4 0x9c ren 0 serial port receive enable bit. set by user software to enable serial port reception. cleared by user software to disable serial port reception. 3 0x9b tb8 0 serial port transmit (bit 9). the data loaded into tb8 is the ninth data bit transmitted in mode 2 and mode 3. 2 0x9a rb8 0 serial port receiver bit 9. the ninth data bi t received in mode 2 and mode 3 is latched into rb8. for mode 1, the stop bit is latched into rb8. 1 0x99 ti 0 serial port transmit interrupt flag. set by hardwa re at the end of the eighth bit in mode 0 or at the beginning of the stop bit in mode 1, mode 2, and mode 3. ti must be cleared by user software. 0 0x98 ri 0 serial port receive interrupt flag. set by hardwa re at the end of the eighth bit in mode 0 or halfway through the stop bit in mode 1, mode 2, and mode 3. ri must be cleared by user software.
ADE7566/ade7569/ade7166/ade7169 rev. a | page 122 of 144 table 133. serial port buffer sfr (sbuf, 0x99) bit mnemonic default description 7 to 0 sbuf 0 serial port data buffer. table 134. enhanced serial baud rate control sfr (sbaudt, 0x9e) bit mnemonic default description 7 owe 0 overwrite error. this bit is set when new data is received and ri = 1. it indicates that sbuf was not read before the next character was transferred in, ca using the prior sbuf data to be lost. write a 0 to this bit to clear it. 6 fe 0 frame error. this bit is set when the received frame did not have a valid stop bit. this bit is read only and updated every time a frame is received. 5 be 0 break error. this bit is set whenever the receive data line (rx) is low for longer than a full transmission frame, which is the time required for a start bit, 8 data bits, a parity bit, and half a stop bit. this bit is updated every time a frame is received. 4, 3 sbth1, sbth0 0 extended divider ratio for baud rate setting as shown in table 136 . 2, 1, 0 div2, div1, div0 0 binary divider. see table 136 . div[2:0] result 000 divide by 1. 001 divide by 2. 010 divide by 4. 011 divide by 8. 100 divide by 16. 101 divide by 32. 110 divide by 64. 111 divide by 128. table 135. uart timer fractional divider sfr (sbaudf, 0x9d) bit mnemonic default description 7 uartbauden 0 uart baud rate enable. set to enable uart timer to generate the baud rate. when set, pcon.7 (smod), t2con.4 (tclk), and t2con.5 (rclk) are ignored. cleared to let the baud rate be generated as per a standard 8052. 6 not implemented, write dont care. 5 sbaudf.5 0 uart timer fractional divider bit 5. 4 sbaudf.4 0 uart timer fractional divider bit 4. 3 sbaudf.3 0 uart timer fractional divider bit 3. 2 sbaudf.2 0 uart timer fractional divider bit 2. 1 sbaudf.1 0 uart timer fractional divider bit 1. 0 sbaudf.0 0 uart timer fractional divider bit 0.
ADE7566/ade7569/ade7166/ade7169 rev. a | page 123 of 144 table 136. common baud rates using uart timer with a 4.096 mhz pll clock ideal baud cd sbth div sbaudt sbaudf % error 115,200 0 0 1 0x01 0x87 +0.16 115,200 1 0 0 0x00 0x87 +0.16 57,600 0 0 2 0x02 0x87 +0.16 57,600 1 0 1 0x01 0x87 +0.16 38,400 0 0 2 0x02 0xab ?0.31 38,400 1 0 1 0x01 0xab ?0.31 38,400 2 0 0 0x00 0xab ?0.31 19,200 0 0 3 0x03 0xab ?0.31 19,200 1 0 2 0x02 0xab ?0.31 19,200 2 0 1 0x01 0xab ?0.31 19,200 3 0 0 0x00 0xab ?0.31 9600 0 0 4 0x04 0xab ?0.31 9600 1 0 3 0x03 0xab ?0.31 9600 2 0 2 0x02 0xab ?0.31 9600 3 0 1 0x01 0xab ?0.31 9600 4 0 0 0x00 0xab ?0.31 4800 0 0 5 0x05 0xab ?0.31 4800 1 0 4 0x04 0xab ?0.31 4800 2 0 3 0x03 0xab ?0.31 4800 3 0 2 0x02 0xab ?0.31 4800 4 0 1 0x01 0xab ?0.31 4800 5 0 0 0x00 0xab ?0.31 2400 0 0 6 0x06 0xab ?0.31 2400 1 0 5 0x05 0xab ?0.31 2400 2 0 4 0x04 0xab ?0.31 2400 3 0 3 0x03 0xab ?0.31 2400 4 0 2 0x02 0xab ?0.31 2400 5 0 1 0x01 0xab ?0.31 2400 6 0 0 0x00 0xab ?0.31 300 0 2 7 0x17 0xab ?0.31 300 1 1 7 0x0f 0xab ?0.31 300 2 0 7 0x07 0xab ?0.31 300 3 0 6 0x06 0xab ?0.31 300 4 0 5 0x05 0xab ?0.31 300 5 0 4 0x04 0xab ?0.31 300 6 0 3 0x03 0xab ?0.31 300 7 0 2 0x02 0xab ?0.31
ADE7566/ade7569/ade7166/ade7169 rev. a | page 124 of 144 all of the following conditions must be met at the time the final shift pulse is generated to receive a character: uart operation modes mode 0 (shift register wi th baud rate fixed at f core /12) ? if the extended uart is disabled (exten = 0 in the cfg sfr), ri must be 0 to receive a character. this ensures that the data in the sbuf sfr is not overwritten if the last received character has not been read. mode 0 is selected when the sm0 and sm1 bits in the serial communications control register bit description sfr (scon, 0x98) are cleared. in this shift register mode, serial data enters and exits through rxd. txd outputs the shift clock. the baud rate is fixed at f core /12. eight data bits are transmitted or received. ? if frame error checking is enabled by setting sm2, the received stop bit must be set to receive a character. this ensures that every character received comes from a valid frame, with both a start bit and a stop bit. transmission is initiated by any instruction that writes to the serial port buffer sfr (sbuf, 0x99). the data is shifted out of the rxd line. the eight bits are transmitted with the least significant bit (lsb) first. if any of these conditions are not met, the received frame is irretrievably lost, and the receive interrupt flag (ri) is not set. reception is initiated when the receive enable bit (ren) is 1 and the receive interrupt bit (ri) is 0. when ri is cleared, the data is clocked into the rxd line, and the clock pulses are output from the txd line as shown in if the received frame has met the previous criteria, the following events occur: ? the eight bits in the receive shift register are latched into the sbuf sfr. figure 102 . rxd (data out) txd (shift clock) data bit 0 data bit 1 data bit 6 data bit 7 06353-078 ? the ninth bit (stop bit) is clocked into rb8 in the scon sfr. ? the receiver interrupt flag (ri) is set. mode 2 (9-bit uart with baud fixed at f core /64 or f core /32) figure 102. 8-bit shift register mode mode 2 is selected by setting sm0 and clearing sm1. in this mode, the uart operates in 9-bit mode with a fixed baud rate. the baud rate is fixed at f core /64 by default, although setting the smod bit in the program control sfr (pcon, 0x87) doubles the frequency to f core /32. eleven bits are transmitted or received: a start bit (0), eight data bits, a programmable ninth bit, and a stop bit (1). the ninth bit is most often used as a parity bit or as part of a multiprocessor communication protocol, although it can be used for anything, including a ninth data bit, if required. mode 1 (8-bit uart, variable baud rate) mode 1 is selected by clearing sm0 and setting sm1. each data byte (lsb first) is preceded by a start bit (0) and followed by a stop bit (1). therefore, each frame consists of 10 bits transmitted on txd or received on rxd. the baud rate is set by a timer overflow rate. timer 1 or timer 2 can be used to generate baud rates, or both timers can be used simultaneously where one generates the transmit rate and the other generates the receive rate. there is also a dedicated timer for baud rate generation, the uart timer, which has a fractional divisor to precisely generate any baud rate (see the to use the ninth data bit as part of a communication protocol for a multiprocessor network such as rs-485, the ninth bit is set to indicate that the frame contains the address of the device with which the master wants to communicate. the devices on the network are always listening for a packet with the ninth bit set and are configured such that if the ninth bit is cleared, the frame is not valid, and a receive interrupt is not generated. if the ninth bit is set, all devices on the network receive the address and obtain a receive character interrupt. the devices examine the address and, if it matches one of the devices preprogrammed addresses, that device configures itself to listen to all incoming frames, even those with the ninth bit cleared. because the master has initiated communication with that device, all the following packets with the ninth bit cleared are intended specifically for that addressed device until another packet with the ninth bit set is received. if the address does not match, the device continues to listen for address packets. uart timer generated baud rates section). transmission is initiated by a write to the serial port buffer sfr (sbuf, 0x99). next, a stop bit (1) is loaded into the ninth bit position of the transmit shift register. the data is output bit-by- bit until the stop bit appears on txd and the transmit interrupt flag (ti) is automatically set as shown in figure 103 . txd ti (scon.1) start bit d0 d1 d2 d3 d4 d5 d6 d7 stop bit set interrupt (for example, ready for more data) 06353-079 figure 103. 8-bit variable baud rate reception is initiated when a 1-to-0 transition is detected on rxd. assuming that a valid start bit is detected, character reception continues. the eight data bits are clocked into the serial port shift register.
ADE7566/ade7569/ade7166/ade7169 rev. a | page 125 of 144 to transmit, the eight data bits must be written into the serial port buffer sfr (sbuf, 0x99). the ninth bit must be written to tb8 in the serial communications control register bit description sfr (scon, 0x98). when transmission is initiated, the eight data bits from sbuf are loaded into the transmit shift register (lsb first). the ninth data bit, held in tb8, is loaded into the ninth bit position of the transmit shift register. the transmission starts at the next valid baud rate clock. the transmit interrupt flag (ti) is set as soon as the transmission completes, when the stop bit appears on txd. all of the following conditions must be met at the time the final shift pulse is generated to receive a character: ? if the extended uart is disabled (exten = 0 in the cfg sfr), ri must be 0 to receive a character. this ensures that the data in sbuf is not overwritten if the last received character has not been read. ? if multiprocessor communication is enabled by setting sm2, the received ninth bit must be set to receive a character. this ensures that only frames with the ninth bit set, frames that contain addresses, generate a receive interrupt. if any of these conditions are not met, the received frame is irretrievably lost, and the receive interrupt flag (ri) is not set. reception for mode 2 is similar to that of mode 1. the eight data bytes are input at rxd (lsb first) and loaded onto the receive shift register. if the received frame has met the previous criteria, the following events occur: ? the eight bits in the receive shift register are latched into the sbuf sfr. ? the ninth data bit is latched into rb8 in the scon sfr. ? the receiver interrupt flag (ri) is set. mode 3 (9-bit uart with variable baud rate) mode 3 is selected by setting both sm0 and sm1. in this mode, the 8052 uart serial port operates in 9-bit mode with a variable baud rate. the baud rate is set by a timer overflow rate. timer 1 or timer 2 can be used to generate baud rates, or both timers can be used simultaneously where one generates the transmit rate and the other generates the receive rate. there is also a dedicated timer for baud rate generation, the uart timer, which has a fractional divisor to precisely generate any baud rate (see the uart timer generated baud rates section). the operation of the 9-bit uart is the same as for mode 2, but the baud rate can be varied. in all four modes, transmission is initiated by any instruction that uses sbuf as a destination register. reception is initiated in mode 0 when ri = 0 and ren = 1. reception is initiated in the other modes by the incoming start bit if ren = 1. uart baud rate generation mode 0 baud rate generation the baud rate in mode 0 is fixed. ? ? ? ? ? ? = 12 core f d rate mode 0 bau mode 2 baud rate generation the baud rate in mode 2 depends on the value of the pcon.7 (smod) bit in the program control sfr (pcon, 0x87). if smod = 0, the baud rate is 1/32 of the core clock. if smod = 1, the baud rate is 1/16 of the core clock. mode 2 baud rate = 32 2 smod f core mode 1 and mode 3 baud rate generation the baud rates in mode 1 and mode 3 are determined by the overflow rate of the timer generating the baud rate, that is, either timer 1, timer 2, or the dedicated baud rate generator, uart timer, which has an integer and fractional divisor. timer 1 generated baud rates when timer 1 is used as the baud rate generator, the baud rates in mode 1 and mode 3 are determined by the timer 1 overflow rate. the value of smod is as follows: mode 1 or mode 3 baud rate = 32 2 smod timer 1 overflow rate the timer 1 interrupt should be disabled in this application. the timer itself can be configured for either timer or counter operation, and in any of its three running modes. in the most typical application, it is configured for timer operation in autoreload mode (high nibble of tmod = 0010 binary). in that case, the baud rate is given by the following formula: mode 1 or mode 3 baud rate = ) 256 ( 32 2 th1 f core smod ? timer 2 generated baud rates baud rates can also be generated by using timer 2. using timer 2 is similar to using timer 1 in that the timer must overflow 16 times before a bit is transmitted or received. because timer 2 has a 16-bit autoreload mode, a wider range of baud rates is possible. mode 1 or mode 3 baud rate = 16 1 timer 2 overflow rate therefore, when timer 2 is used to generate baud rates, the timer increments every two clock cycles rather than every core machine cycle as before. it increments six times faster than timer 1, and, therefore, baud rates six times faster are possible. because timer 2 has 16-bit autoreload capability, very low baud rates are still possible. timer 2 is selected as the baud rate generator by setting tclk and/or rclk in timer/counter 2 control sfr (t2con, 0xc8).
ADE7566/ade7569/ade7166/ade7169 rev. a | page 126 of 144 timer 2 is selected as the baud rate generator by setting tclk and/or rclk in timer/counter 2 control sfr (t2con, 0xc8). the baud rates for transmit and receive can be simultaneously different. setting rclk and/or tclk puts timer 2 into its baud rate generator mode, as shown in figure 105 . in this case, the baud rate is given by the following formula: mode 1 or mode 3 baud rate = () [] () lrcaphrcap f core 2:2 6553616 ? (1 + sbaudf/64) uart timer rx/tx clock f core uartbauden rx clock tx clock timer 1/timer 2 rx clock fractional divide r 0 0 1 1 timer 1/timer 2 tx clock 32 2 div + sbth 06353-081 figure 104. uart timer, uart baud rate uart timer generated baud rates two sfrs, enhanced serial baud rate control sfr (sbaudt, 0x9e) and uart timer fractional divider sfr (sbaudf, 0x9d), are used to control the uart timer. sbaudt is the baud rate control sfr; it sets up the integer divider (div) and the extended divider (sbth) for the uart timer. the high integer dividers in a uart block mean that high speed baud rates are not always possible. in addition, generating baud rates requires the exclusive use of a timer, rendering it unusable for other applications when the uart is required. to address this problem, each ADE7566/ade7569/ade7166/ade7169 has a dedicated baud rate timer (uart timer) specifically for generating highly accurate baud rates. the uart timer can be used instead of timer 1 or timer 2 for generating very accurate high speed uart baud rates, including 115,200 bps. this timer also allows a much wider range of baud rates to be obtained. in fact, every desired bit rate from 12 bps to 393,216 bps can be generated to within an error of 0.8%. the uart timer also frees up the other three timers, allowing them to be used for different applications. a block diagram of the uart timer is shown in the appropriate value to write to the div[2:0] and sbth[1:0] bits can be calculated using the following formula where f core is defined in the powcon sfr (see tabl e 25 ). note that the div value must be rounded down to the nearest integer. () 2log 16 log ? ? ? ? ? ? ? ? =+ ratebaud f sbth div core figure 104 . f core t2 pin tr2 control tl2 (8 bits) th2 (8 bits) reload exen2 control t2ex pin transition detector exf 2 timer 2 interrupt rcap2l rcap2h timer 2 overflow 2 16 16 rclk tclk rx clock tx clock 0 0 1 1 10 smod timer 1 overflow c/ t2 = 0 c/ t2 = 1 note: availability of additional external interrupt 06353-080 figure 105. timer 2, uart baud rates
ADE7566/ade7569/ade7166/ade7169 rev. a | page 127 of 144 rx ri fe exten = 1 d7 d6 d5d4 d3 d2 d1 d0 stop start 06353-082 sbaudf is the fractional divider ratio required to achieve the required baud rate. the appropriate value for sbaudf can be calculated with the following formula: ? ? ? ? ? ? ? ? ? = + 1 216 64 ratebaud f sbaudf sbthdiv core figure 106. uart timing in mode 1 note that sbaudf should be rounded to the nearest integer. after the values for div and sbaudf are calculated, the actual baud rate can be calculated with the following formula: rx ri fe exten = 1 d7 d6d5 d4 d3 d2d1d0 d8 stop start 06353-083 ? ? ? ? ? ? + = + 64 1 216 sbaudf f ratebaudactual sbth div core figure 107. uart timing in mode 2 and mode 3 for example, to obtain a baud rate of 9600 bps while operating at a core clock frequency of 4.096 mhz with the pll cd bits equal to 0, the 8052 standard uart does not provide break error detection. however, for an 8-bit uart, a break error can be detected when the received character is 0, a null character, and when there is no stop bit because the rb8 bit is low. break error detection is not possible for a 9-bit 8052 uart because the stop bit is not recorded. the ADE7566/ade7569/ade7166/ade7169 enhanced break error detection is available through the be bit in the sbaudt sfr. () 474.4 2log 960016 4,096,000 log == ? ? ? ? ? ? =+ sbth div note that the div result is rounded down. 0x2b67.421 9600216 000,096,4 64 3 == ? ? ? ? ? ? ? = sbaudf the 8052 standard uart prevents overwrite errors by not allowing a character to be received when the ri, receive interrupt flag, is set. however, it does not indicate if a character has been lost because the ri bit is set when the frame is received. the enhanced uart overwrite error detection provides this infor- mation. when the enhanced 8052 uart is enabled, a frame is received regardless of the state of the ri flag. if ri = 1 when a new byte is received, the byte in scon is overwritten, and the overwrite error flag is set. the overwrite error flag is cleared when sbuf is read. thus, the actual baud rate is 9570 bps, resulting in a 0.31% error. uart additional features enhanced error checking the extended uart provides frame error, break error, and overwrite error detection. framing errors occur when a stop bit is not present at the end of the frame. a missing stop bit implies that the data in the frame may not have been received properly. break error detection indicates whether the rx line has been low for longer than a 9-bit frame. it indicates that the data just received, a 0 or null character, is not valid because the master has disconnected. overwrite error detection indicates when the received data has not been read fast enough and, as a result, a byte of data has been lost. the extended uart is enabled by setting the exten bit in the configuration sfr (cfg, 0xaf). uart txd signal modulation there is an internal 38 khz signal that can be ored with the uart transmit signal for use in remote control applications (see the 38 khz modulation section). the 8052 standard uart offers frame-error checking for an 8-bit uart through the sm2 and rb8 bits. setting the sm2 bit prevents frames without a stop bit from being received. the stop bit is latched into the rb8 bit in the serial communications control register bit description sfr (scon, 0x98). this bit can be examined to determine if a valid frame was received. the 8052 does not, however, provide frame error checking for a 9-bit uart. this enhanced error checking functionality is available through the frame error bit, fe, in the enhanced serial baud rate control sfr (sbaudt, 0x9e). the fe bit is set on framing errors for both 8-bit and 9-bit uarts. one of the events that can wake the mcu from sleep mode is activity on the rx pin (see the 3.3 v peripherals and wake-up events section).
ADE7566/ade7569/ade7166/ade7169 rev. a | page 128 of 144 serial peripheral interface (spi) the ADE7566/ade7569/ade7166/ade7169 integrate a complete hardware serial peripheral interface on-chip. the spi is full duplex so that eight bits of data are synchronously transmitted and simultaneously received. this spi implementation is double buffered, allowing users to read the last byte of received data while a new byte is shifted in. the next byte to be transmitted can be loaded while the current byte is shifted out. the spi port can be configured for master or slave operation. the physical interface to the spi is via the miso (p0.5), mosi (p0.4), sclk (p0.6), and ss (p0.7) pins, while the firmware interface is via the spi configuration sfr 1 (spimod1, 0xe8), the spi configuration sfr 2 (spimod2, 0xe9), the spi interrupt status sfr (spistat, 0xea), the spi/i 2 c transmit buffer sfr (spi2ctx, 0x9a), and the spi/i 2 c receive buffer sfr (spi2crx, 0x9b). note that the spi pins are shared with the i 2 c pins. therefore, the user can enable only one interface at a time. the scps bit in the configuration sfr (cfg, 0xaf) selects which peripheral is active. spi registers table 137. spi sfr list sfr address name r/w length default description 0x9a spi2ctx w 8 spi/i 2 c transmit buffer (see table 138 ). 0x9b spi2crx r 8 0 spi/i 2 c receive buffer (see table 139 ). 0xe8 spimod1 r/w 8 0x10 spi configuration sfr 1 (see table 140 ). 0xe9 spimod2 r/w 8 0 spi configuration sfr 2 (see table 141 ). 0xea spistat r/w 8 0 spi/i 2 c interrupt status (see table 142 ). table 138. spi/i 2 c transmit buffer sfr (spi2ctx, 0x9a) bit mnemonic default description 7 to 0 spi2ctx 0 spi or i 2 c transmit buffer. when spi2ctx sfr is written, its content is transferred to the transmit fifo input. when a write is requested, the fifo output is sent on the spi or i 2 c bus. table 139. spi/i 2 c receive buffer sfr (spi2crx, 0x9b) bit mnemonic default description 7 to 0 spi2crx 0 spi or i 2 c receive buffer. when spi2crx sfr is read, one byte from the receive fifo output is transferred to spi2crx sfr. a new data byte from the spi or i 2 c bus is written to the fifo input.
ADE7566/ade7569/ade7166/ade7169 rev. a | page 129 of 144 table 140. spi configuration sfr 1 (spimod1, 0xe8) bit address mnemonic default description 7 to 6 0xef to 0xee reserved 0 reserved. 5 0xed intmod 0 spi interrupt mode. intmod result 0 spi interrupt is set when spi rx buffer is full. 1 spi interrupt is set when spi tx buffer is empty. 4 0xec auto_ss 1 master mode, ss output control (see figure 108 ). auto_ss result 0 the ss pin is held low while this bit is clea red. this allows manual chip select control using the ss pin. single byte read or write. the ss pin goes low during a single byte transmission and then returns high. 1 continuous transfer. the ss pin goes low during the duration of the multibyte continuous transfer an d then returns high. 3 0xeb ss_en 0 slave mode, ss input enable. when this bit is set to logic 1, the ss pin is defined as the slave select input pin for the spi slave interface. 2 0xea rxofw 0 receive buffer overflow write enable. rxofw result 0 if the spi2crx sfr has not been read when a new data byte is received, the new byte is discarded. 1 if the spi2crx sfr has not been read when a new data byte is received, the new byte overwrites the old data. 1 to 0 0xe9 to 0xe8 spir[1:0] 0 master mode, spi sclk frequency. spir[1:0] result 00 f core /8 = 512 khz (if f core = 4.096 mhz) 01 f core /16 = 256 khz (if f core = 4.096 mhz) 10 f core /32 = 128 khz (if f core = 4.096 mhz) 11 f core /64 = 64 khz (if f core = 4.096 mhz)
ADE7566/ade7569/ade7166/ade7169 rev. a | page 130 of 144 table 141. spi configuration sfr 2 (spimod2, 0xe9) bit mnemonic default description master mode, spi continuous transfer mode enable bit. spicont result 0 the spi interface stops after one byte is transferred and ss is deasserted. a new data transfer can be initiated after a stalled period. 7 spicont 0 1 the spi interface continues to transfer data until no valid data is available in the spi2ctx sfr. ss remains asserted until the spi2ctx sfr and the transmit shift registers are empty. spi interface enable bit. spien result 0 the spi interface is disabled. 6 spien 0 1 the spi interface is enabled. spi open-drain output configuration bit. spiodo result 0 internal pull-up resistors are connected to the spi outputs. 5 spiodo 0 1 the spi outputs are open drain and need external pull-up resistors. the pull-up voltage should not exceed the specified operating voltage. spi master mode enable bit. spims_b result 0 the spi interface is defined as a slave. 4 spims_b 0 1 the spi interface is defined as a master. spi clock polarity configuration bit (see figure 110 ). spicpol result 0 the default state of sclk is low, and the first sc lk edge is rising. depending on the spicpha bit, the spi data output changes state on the falling or rising edge of sclk whil e the spi data input is sampled on the rising or falling edge of sclk. 3 spicpol 0 1 the default state of sclk is high, and the firs t sclk edge is falling. depending on the spicpha bit, the spi data output changes state on the risi ng or falling edge of sclk while the spi data input is sampled on the falling or rising edge of sclk. spi clock phase configuration bit (see figure 110 ). spicpha result 0 the spi data output changes state when ss goes low at the second edge of sclk and then every two subsequent edges, whereas the spi data inp ut is sampled at the firs t sclk edge and then every two subsequent edges. 2 spicpha 0 1 the spi data output changes state at the first edge of sclk and then every two subsequent edges, whereas the spi data input is sampled at the second sclk edge and then every two subsequent edges. master mode, lsb first configuration bit. spilsbf result 0 the msb of the spi outputs is transmitted first. 1 spilsbf 0 1 the lsb of the spi outputs is transmitted first. transfer and interrupt mode of the spi interface. timode result 0 timode 1 1 this bit must be left set for proper operation.
ADE7566/ade7569/ade7166/ade7169 rev. a | page 131 of 144 table 142. spi interrupt status sfr (spistat, 0xea) bit mnemonic default description spi peripheral busy flag. busy result 0 the spi peripheral is idle. 7 busy 0 1 the spi peripheral is bu sy transferring data in slave or master mode. spi multimaster error flag. mmerr result 0 a multiple master error has not occurred. 6 mmerr 0 1 if the ss_en bit is set, enabling th e slave select input and asserting the ss pin while the spi peripheral is transferring data as a master, th is flag is raised to indicate the error. write a 0 to this bit to clear it. spi receive overflow error flag. reading the spi2crx sfr clears this bit. spirxof timode result 0 x the spi2crx register contains valid data. 5 spirxof 0 1 1 this bit is set if the spi2crx register is not read before the end of the next byte transfer. if the rxofw bit is set and this condition occurs, spi2crx is overwritten. spi receive mode interrupt flag. reading the spi2crx sfr clears this bit. spirxirq timode result 0 x the spi2crx register does not contain new data. 1 0 this bit is set when the spi2crx register contains new data. if the spi/i 2 c interrupt is enabled, an inte rrupt is generated when this bit is set. if the spi2crx register is not read before the end of th e current byte transfer, the transfer stops and the ss pin is deasserted. 4 spirxirq 0 1 1 the spi2crx register contains new data. 3 spirxbf 0 status bit for spi rx buffer. when set, the rx fifo is full. a read of the spi2crx clears this flag. 2 spitxuf 0 status bit for spi tx buffer. when set, the tx fifo is underflowing and data can be written into spi2ctx. write a 0 to this bit to clear it. spi transmit mode interrupt flag. writing new data to the spi2ctx sfr clears this bit. spitxirq timode result 0 x the spi2ctx register is full. 1 0 the spi2ctx register is empty. 1 spitxirq 0 1 1 this bit is set when the spi2ctx register is empty. if the spi/i 2 c interrupt is enabled, an interrupt is gene rated when this bit is set. if new data is not written into the spi2ctx sfr before the end of the current byte transfer, the transfer stops, and the ss pin is deasserted. write a 0 to this bit to clear it. 0 spitxbf 0 status bit for spi tx buffer. when set, the sp i tx buffer is full. write a 0 to this bit to clear it. spi pins miso (master in, slave out data i/o pin) the miso pin is configured as an input line in master mode and as an output line in slave mode. the miso line on the master (data in) should be connected to the miso line in the slave device (data out). the data is transferred as byte-wide (8-bit) serial data, msb first. mosi (master out, slave in pin) the mosi pin is configured as an output line in master mode and as an input line in slave mode. the mosi line on the master (data out) should be connected to the mosi line in the slave device (data in).the data is transferred as byte-wide (8-bit) serial data, msb first. sclk (serial clock i/o pin) the master serial clock (sclk) is used to synchronize the data being transmitted and received through the mosi and miso data lines. the sclk pin is configured as an output in master mode and as an input in slave mode. in master mode, the bit rate, polarity, and phase of the clock are controlled by the spi configuration sfr 1 (spimod1, 0xe8) and spi configuration sfr 2 (spimod2, 0xe9). in slave mode, the spi configuration sfr 2 (spimod2, 0xe9) must be configured with the phase and polarity of the expected input clock. in both master and slave modes, the data is transmitted on one edge of the sclk signal and sampled on the other. it is important, therefore, that the spicpha and spicpol bits be configured the same for the master and slave devices.
ADE7566/ade7569/ade7166/ade7169 rev. a | page 132 of 144 sclk ss dout din din1 din2 auto_ss = 1 spicont = 0 sclk ss dout din din1 auto_ss = 1 spicont = 1 din2 auto_ss = 0 spicont = 0 (manual ss control) dout1 dout2 dout1 dout2 sclk ss dout din din1 din2 dout1 dout2 06353-084 ss (slave select pin) ss in spi slave mode, a transfer is initiated by the assertion of low. the spi port then transmits and receives 8-bit data until the data is concluded by the deassertion of ss according to the spicon bit setting. in slave mode, ss is always an input. in spi master mode, the ss can be used to control data transfer to a slave device. in the automatic slave select control mode, the ss is asserted low to select the slave device and then raised to deselect the slave device after the transfer is complete. automatic slave select control is enabled by setting the auto_ss bit in the spi configuration sfr 1 (spimod1, 0xe8). ss in a multimaster system, the can be configured as an input so that the spi peripheral can operate as a slave in some situations and as a master in others. in this case, the slave selects for the slaves controlled by this spi peripheral should be generated with general i/o pins. spi master operating modes the double buffered receive and transmit registers can be used to maximize the throughput of the spi peripheral by continuously streaming out data in master mode. the continuous transmit mode is designed to use the full capacity of the spi. in this mode, the master transmits and receives data until the spi/i 2 c transmit buffer sfr (spi2ctx, 0x9a) is empty at the start of a byte transfer. continuous mode is enabled by setting the spicont bit in the spi configuration sfr 2 (spimod2, 0xe9). the spi peripheral also offers a single byte read/write function. in master mode, the type of transfer is handled automatically, depending on the configuration of the spicont bit in the spi configuration sfr 2 (spimod2, 0xe9). figure 108. automatic chip select and continuous mode output note that reading the content of the spi/i 2 c receive buffer sfr (spi2crx, 0x9b) should be done using a 2-cycle instruction set such as mov a or spi2crx. using a 3-cycle instruction such as mov 0x3d or spi2crx does not transfer the right information into the target register. table 143 shows the sequence of events that should be performed for each master operating mode. based on the ss configuration, some of these events take place automatically. figure 108 shows the spi output for certain automatic chip select and continuous mode selections. note that if the continuous mode is not used, a short delay is inserted between transfers. table 143. procedures for using spi as a master spimod2[7] = spicont bit mode description of operation step 1. write to spi2ctx sfr. single byte write 0 step 2. ss is asserted low and a write routine is initiated. step 3. spitxirq interrupt flag is se t when the spi2ctx register is empty. step 4. ss is deasserted high. step 5. write to spi2ctx sfr to clear the spitxirq interrupt flag. step 1. write to spi2ctx sfr. continuous 1 step 2. ss is asserted low and write routine is initiated. step 3. wait for the spitxirq interrupt flag to write to spi2ctx sfr. transfer continues until the spi2ctx register and transmit shift registers are empty. step 4. spitxirq interrupt flag is se t when the spi2ctx register is empty. step 5. ss is deasserted high. step 6. write to spi2ctx sfr to clear the spitxirq interrupt flag.
ADE7566/ade7569/ade7166/ade7169 rev. a | page 133 of 144 spi interrupt and status flags the spi interface has several status flags that indicate the status of the double-buffered receive and transmit registers. figure 109 shows when the status and interrupt flags are raised. the transmit interrupt occurs when the transmit shift register is loaded with the data in the spi/i 2 c transmit buffer sfr (spi2ctx, 0x9a) register. if the spi master is in transmit operating mode, and the spi/i 2 c transmit buffer sfr (spi2ctx, 0x9a) register has not been written with new data by the beginning of the next byte transfer, the transmit operation stops. when a new byte of data is received in the spi/i 2 c receive buffer sfr (spi2crx, 0x9b) register, the spi receive interrupt flag is raised. if the data in the spi/i 2 c receive buffer sfr (spi2crx, 0x9b) register is not read before new data is ready to be loaded into the spi/i 2 c receive buffer sfr (spi2crx, 0x9b), an overflow condition has occurred. this overflow condition, indicated by the spirxof flag, forces the new data to be discarded or overwritten if the rxofw bit is set. spitx transmit shift register spitxirq = 1 spitx (empty) transmit shift register stops transfer if timode = 1 spirx receive shift register spirxirq = 1 spirx (full) receive shift register spirxof = 1 06353-085 figure 109. spi receive and transmit interrupt and status flags sclk (spicpol=0) miso sclk (spicpol = 1) mosi spirx1 and spitx1 flags ss_b spirx0 and spitx0 flags spicpha = 1 msb bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 lsb ? msb bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 lsb ? msb bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 lsb ? msb bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 lsb ? miso mosi spirx1 and spitx1 flags spirx0 and spitx0 flags s picpha = 0 06353-086 figure 110. spi timi ng configurations
ADE7566/ade7569/ade7166/ade7169 rev. a | page 134 of 144 i 2 c compatible interface the bit rate is defined in the i2cmod sfr as follows: the ADE7566/ade7569/ade7166/ade7169 support a fully licensed i 2 c interface. the i 2 c interface is implemented as a full hardware master. ]0:1[2 216 cri core sclk f f = sdata is the data i/o pin, and sclk is the serial clock. these two pins are shared with the mosi and sclk pins of the on-chip spi interface. therefore, the user can enable only one interface or the other on these pins at any given time. the scps bit in the configuration sfr (cfg, 0xaf) selects which peripheral is active. slave addresses the i 2 c slave address sfr (i2cadr, 0xe9) contains the slave device id. the lsb of this register contains a read/write request. a write to this sfr starts the i 2 c communication. i 2 c registers the two pins used for data transfer, sdata and sclk, are configured in a wire-and format that allows arbitration in a multimaster system. the i 2 c peripheral interface consists of five sfrs: ? i2cmod ? spi2cstat the transfer sequence of an i 2 c system consists of a master device initiating a transfer by generating a start condition while the bus is idle. the master transmits the address of the slave device and the direction of the data transfer in the initial address transfer. if the slave acknowledges, the data transfer is initiated. this continues until the master issues a stop condition and the bus becomes idle. ? i2cadr ? spi2ctx ? spi2crx because the spi and i 2 c serial interfaces share the same pins, they also share the same sfrs, such as the spi2ctx and spixcrx sfrs. in addition, the i2cmod, i2cadr, spi2cstat, and spi2ctx sfrs are shared with the spimod1, spimod2, and spistat sfrs, respectively. serial clock generation the i 2 c master in the system generates the serial clock for a transfer. the master channel can be configured to operate in fast mode (256 khz) or standard mode (32 khz). table 144. i 2 c sfr list sfr address name r/w length default description 0x9a spi2ctx w 8 spi/i 2 c transmit buffer (see table 138 ). 0x9b spi2crx r 8 0 spi/i 2 c receive buffer (see table 139 ). 0xe8 i2cmod r/w 8 0 i 2 c mode (see table 145 ). 0xe9 i2cadr r/w 8 0 i 2 c slave address (see table 146 ). 0xea spi2cstat r/w 8 0 i 2 c interrupt status register (see table 147 ). table 145. i 2 c mode sfr (i2cmod, 0xe8) bit address mnemonic default description 7 0xef i2cen 0 i 2 c enable bit. when this bit is set to logic 1, the i 2 c interface is enabled. a write to the i2cadr sfr starts a communication. 6 to 5 0xee to 0xed i2cr[1:0] 0 i 2 c sclk frequency. i2cr[1:0] result 00 f core /16 = 256 khz if f core = 4.096 mhz 01 f core /32 = 128 khz if f core = 4.096 mhz 10 f core /64 = 64 hz if f core = 4.096 mhz 11 f core /128= 32 khz if f core = 4.096 mhz 4 to 0 0xec to 0xe8 i2crct[4:0] 0 configures the length of the i 2 c received fifo buffer. the i 2 c peripheral stops when i2crct, bit[4:0] + 1 byte have been read or if an error occurs. table 146. i 2 c slave address sfr (i2cadr, 0xe9) bit mnemonic default description 7 to 1 i2cslvadr 0 address of the i 2 c slave being addressed. writing to this register starts the i 2 c transmission (read or write). 0 i2cr_w 0 command bit for read or write. when this bit is se t to logic 1, a read command is transmitted on the i 2 c bus. data from the slave in the spi2crx sfr is ex pected after a command byte. when this bit is set to logic 0, a write command is transmitted on the i 2 c bus. data to slave is expected in the spi2ctx sfr.
ADE7566/ade7569/ade7166/ade7169 rev. a | page 135 of 144 table 147. i 2 c interrupt status register sfr (spi2cstat, 0xea) bit mnemonic default description 7 i2cbusy 0 this bit is set to logic 1 when the i 2 c interface is used. when set, the tx fifo is emptied. 6 i2cnoack 0 i 2 c no acknowledgement transmit interrupt. this bit is set to logic 1 when the slave device does not send an acknowledgement. the i 2 c communication is stopped after this event. write a 0 to this bit to clear it. 5 i2crxirq 0 i 2 c receive interrupt. this bit is set to logi c 1 when the receive fifo is not empty. write a 0 to this bit to clear it. 4 i2ctxirq 0 i 2 c transmit interrupt. this bit is set to lo gic 1 when the transmit fifo is empty. write a 0 to this bit to clear it. 3 to 2 i2cfifostat[1:0] 0 status bits for 3- or 4-bytes deep i 2 c fifo. the fifo monitored in these two bits is the one currently used in i 2 c communication (receive or transmit) because only one fifo is active at a time. i2cfifostat[1:0] result 00 fifo empty 01 reserved 10 fifo half full 11 fifo full 1 i2cacc_err 0 set when trying to write and read at the same time. write a 0 to this bit to clear it. 0 i2ctxwr_err 0 set when write was attempted when i 2 c transmit fifo was full. write a 0 to this bit to clear it. read and write operations sclk sdata start by master ack by slave ack by master frame 2 data byte 1 from master frame 1 serial bus address byte 19 9 1 a0a1a2a3a4a5a6 r/w d0d1d2d3d4d5 d6 d7 9 1 d0d1d2d3d4d5d6d7 frame n + 1 data byte n from slave stop by master nack by master 0 6353-087 figure 111. i 2 c read operation sclk sdata start by master ack by slave ack by slave frame 2 data byte 1 from master frame 1 serial bus address byte 19 1 9 stop by master a0a1a2a3a4a5a6 r/w d0 d1d2d3 d4 d5d6d7 06353-088 figure 112. i 2 c write operation reading the spi/i 2 c receive buffer sfr (spi2crx, 0x9b) figure 111 and figure 112 depict i 2 c read and write operations, respectively. note that the lsb of the i2cadr register is used to select whether a read or write operation is performed on the slave device. during the read operation, the master acknowledges are generated automatically by the i 2 c peripheral. the master generated nack (no acknowledge) before the end of a read operation is also automatically generated after the i2crct bits[4:0] have been read from the slave. if the i2cadr register is updated during a transmission, instead of generating a stop at the end of the read or write operation, the master generates a start condition and continues with the next communication. reading the spi2crx sfr should be done with a 2-cycle instruction, such as mov a, spi2crx or mov r0, spi2crx . a 3-cycle instruction such as mov 3dh, spi2crx does not transfer the right data into ram address 0x3d.
ADE7566/ade7569/ade7166/ade7169 rev. a | page 136 of 144 i 2 c receive and transmit fifos the i 2 c peripheral has a 4-byte receive fifo and a 4-byte transmit fifo. the buffers reduce the overhead associated with using the i 2 c peripheral. figure 113 shows the operation of the i 2 c receive and transmit fifos. the tx fifo can be loaded with four bytes to be transmitted to the slave at the beginning of a write operation. when the transmit fifo is empty, the i 2 c transmit interrupt flag is set, and the pc vectors to the i 2 c interrupt vector if this interrupt is enabled. if a new byte is not loaded into the tx fifo before it is needed in the transmit shift register, the communication stops. an error, such as not receiving an acknowledge, also causes the communication to terminate. in case of an error during a write operation, the tx fifo is flushed. the rx fifo allows four bytes to be read in from the slave before the mcu has to read the data. a receive interrupt can be generated after each byte is received or when the rx fifo is full. if the peripheral is reading from a slave address, the communication stops once the number of received bytes equals the number set in the i2crct, bits[4:0]. an error, such as not receiving an acknowledge, also causes the communication to terminate. i 2 ctx 4 byte fifo mov i 2 ctx, txdata1 mov i 2 ctx, txdata2 mov i 2 ctx, txdata3 mov i 2 ctx, txdata4 code to fill tx fifo: transmit shift register i 2 crx receive shift register 4 byte fifo code to read rx fifo: mov a, i 2 crx; result: a = rxdata1 mov a, i 2 crx; result: a = rxdata2 mov a, i 2 crx; result: a = rxdata3 mov a, i 2 crx; result: a = rxdata4 txdata1 txdata2 txdata3 txdata4 rxdata4 rxdata3 rxdata2 rxdata1 06353-089 figure 113. i 2 c fifo operation
ADE7566/ade7569/ade7166/ade7169 rev. a | page 137 of 144 i/o ports weak internal pull-ups enabled parallel i/o a pin with weak internal pull-up enabled is used as an input by writing a 1 to the pin. the pin is pulled high by the internal pull- ups, and the pin is read using the circuitry shown in the ADE7566/ade7569/ade7166/ade7169 use three input/output ports to exchange data with external devices. in addition to performing general-purpose i/o, some are capable of driving an lcd or performing alternate functions for the peripherals available on-chip. in general, when a peripheral is enabled, the pins associated with it cannot be used as a general- purpose i/o. the i/o port can be configured through the sfrs in figure 114 . if the pin is driven low externally, it sources current because of the internal pull-ups. a pin with internal pull-up enabled is used as an output by writing a 1 or a 0 to the pin to control the level of the output. if a 0 is written to the pin, it drives a logic low output voltage (v ol ) and is capable of sinking 1.6 ma. table 148 . table 148. i/o port sfrs open drain (weak internal pull-ups disabled) sfr address bit addressable description when the weak internal pull-up on a pin is disabled, the pin becomes open drain. use this open-drain pin as a high impedance input by writing a 1 to the pin. the pin is read using the circuitry shown in p0 0x80 yes port 0 register. p1 0x90 yes port 1 register. p2 0xa0 yes port 2 register. figure 114 . the open-drain option is preferable for inputs because it draws less current than the internal pull-ups that were enabled. epcfg 0x9f no extended port configuration. pinmap0 0xb2 no port 0 weak pull-up enable. 38 khz modulation pinmap1 0xb3 no port 1 weak pull-up enable. every ADE7566/ade7569/ade7166/ade7169 provides a 38 khz modulation signal. the 38 khz modulation is accomplished by internally xoring the level written to the i/o pin with a 38 khz square wave. then, when a 0 is written to the i/o pin, it is modulated as shown in pinmap2 0xb4 no port 2 weak pull-up enable. the three bidirectional i/o ports have internal pull-ups that can be enabled or disabled individually for each pin. the internal pull-ups are enabled by default. disabling an internal pull-up causes a pin to become open drain. weak internal pull-ups are configured through the pinmapx sfrs. figure 115 . 38khz modulation signal output at mod38 pin level written to mod38 06353-091 figure 114 shows a typical bit latch and i/o buffer for an i/o pin. the bit latch (one bit in each ports sfr) is represented as a type d flip-flop, which clocks in a value from the internal bus in response to a write-to-latch signal from the cpu. the q output of the flip-flop is placed on the internal bus in response to a read latch signal from the cpu. the level of the port pin itself is placed on the internal bus in response to a read pin signal from the cpu. some instructions that read a port activate the read latch signal, and others activate the read pin signal. see the figure 115. 38 khz modulation uses for this 38 khz modulation include ir modulation of a uart transmit signal or a low power signal to drive an led. the modulation can be enabled or disabled with the mod38en bit in the cfg sfr. the 38 khz modulation is available on eight pins, selected by the mod38[7:0] bits in the extended port configuration sfr (epcfg, 0x9f). read-modify-write instructions section for details. read latch internal bus write to latch read pin d cl q latch dv dd px.x pin internal pull-up alternate output function alternate input function q closed: pinmapx.x = 0 open: pinmapx.x = 1 06353-090 figure 114. port 0 bit latch and i/o buffer
ADE7566/ade7569/ade7166/ade7169 rev. a | page 138 of 144 i/o registers table 149. extended port configuration sfr (epcfg, 0x9f) bit mnemonic default description 7 mod38_fp21 0 enable 38 khz modulation on p1.6/fp21 pin. 6 mod38_fp22 0 enable 38 khz modulation on p1.5/fp22 pin. 5 mod38_fp23 0 enable 38 khz modulation on p1.4/t2/fp23 pin. 4 mod38_txd 0 enable 38 khz modulation on p1.1/txd pin. 3 mod38_cf1 0 enable 38 khz modulation on p0.2/cf1/rtccal pin. 2 mod38_ssb 0 enable 38 khz modulation on p0.7/ ss /t1pin. 1 mod38_miso 0 enable 38 khz modulation on p0.5/miso pin. 0 mod38_cf2 0 enable 38 khz modulation on p0.3/cf2 pin. table 150. port 0 weak pull-up enable sfr (pinmap0, 0xb2) bit mnemonic default description 7 pinmap0.7 0 the weak pull-up on p0.7 is disabled when this bit is set. 6 pinmap0.6 0 the weak pull-up on p0.6 is disabled when this bit is set. 5 pinmap0.5 0 the weak pull-up on p0.5 is disabled when this bit is set. 4 pinmap0.4 0 the weak pull-up on p0.4 is disabled when this bit is set. 3 pinmap0.3 0 the weak pull-up on p0.3 is disabled when this bit is set. 2 pinmap0.2 0 the weak pull-up on p0.2 is disabled when this bit is set. 1 pinmap0.1 0 the weak pull-up on p0.1 is disabled when this bit is set. 0 pinmap0.0 0 the weak pull-up on p0.0 is disabled when this bit is set. table 151. port 1 weak pull-up enable sfr (pinmap1, 0xb3) bit mnemonic default description 7 pinmap1.7 0 the weak pull-up on p1.7 is disabled when this bit is set. 6 pinmap1.6 0 the weak pull-up on p1.6 is disabled when this bit is set. 5 pinmap1.5 0 the weak pull-up on p1.5 is disabled when this bit is set. 4 pinmap1.4 0 the weak pull-up on p1.4 is disabled when this bit is set. 3 pinmap1.3 0 the weak pull-up on p1.3 is disabled when this bit is set. 2 pinmap1.2 0 the weak pull-up on p1.2 is disabled when this bit is set. 1 pinmap1.1 0 the weak pull-up on p1.1 is disabled when this bit is set. 0 pinmap1.0 0 the weak pull-up on p1.0 is disabled when this bit is set. table 152. port 2 weak pull-up enable sfr (pinmap2, 0xb4) bit mnemonic default description 7 to 6 reserved 0 reserved. should be left cleared. 5 pinmap2.5 0 the weak pull-up on reset is disabled when this bit is set. 4 reserved 0 reserved. should be left cleared. 3 pinmap2.3 0 reserved. should be left cleared. 2 pinmap2.2 0 the weak pull-up on p2.2 is disabled when this bit is set. 1 pinmap2.1 0 the weak pull-up on p2.1 is disabled when this bit is set. 0 pinmap2.0 0 the weak pull-up on p2.0 is disabled when this bit is set.
ADE7566/ade7569/ade7166/ade7169 rev. a | page 139 of 144 table 153. port 0 sfr (p0, 0x80) bit address mnemonic default description 1 7 0x87 t1 1 this bit reflects the state of p0.7/ ss /t1 pin. it can be written or read. 6 0x86 t0 1 this bit reflects the state of p0 .6/sclk/t0 pin. it can be written or read. 5 0x85 1 this bit reflects the state of p0.5/miso pin. it can be written or read. 4 0x84 1 this bit reflects the state of p0.4/mosi/sdata pin. it can be written or read. 3 0x83 cf2 1 this bit reflects the state of p0.3/cf2 pin. it can be written or read. 2 0x82 cf1 1 this bit reflects the state of p0.2/cf1 pin. it can be written or read. 1 0x81 1 this bit reflects the state of p0.1/fp19 pin. it can be written or read. 0 0x80 int1 1 this bit reflects the state of bctrl/ int1 /p0.0 pin. it can be written or read. 1 when an alternate function is chosen for a pin of this port, the bit controlling this pin should always be set. table 154. port 1 sfr (p1, 0x90) bit address mnemonic default description 1 7 0x97 1 this bit reflects the state of p1.7/fp20 pin. it can be written or read. 6 0x96 1 this bit reflects the state of p1.6/fp2 pin. it can be written or read. 5 0x95 1 this bit reflects the state of p1.5/fp22 pin. it can be written or read. 4 0x94 t2 1 this bit reflects the state of p1.4/t2/fp23 pin. it can be written or read. 3 0x93 t2ex 1 this bit reflects the state of p1.3/t2ex/fp24 pin. it can be written or read. 2 0x92 1 this bit reflects the state of p1.2/fp25 pin. it can be written or read. 1 0x91 txd 1 this bit reflects the state of p1.1/txd pin. it can be written or read. 0 0x90 rxd 1 this bit reflects the state of p1.0/rxd pin. it can be written or read. 1 when an alternate function is chosen for a pin of this port, the bit controlling this pin should always be set. table 155. port 2 sfr (p2, 0xa0) bit address mnemonic default description 1 7 to 4 0x97 to 0x94 0x1f these bits are unused and should remain set. 3 0x93 p2.3 1 this bit reflects the state of p2.3/sden pin. it can be written only. 2 0x92 p2.2 1 this bit reflects the state of p2.2/fp16 pin. it can be written or read. 1 0x91 p2.1 1 this bit reflects the state of p2.1/fp17 pin. it can be written or read. 0 0x90 p2.0 1 this bit reflects the state of p2.0/fp18 pin. it can be written or read. 1 when an alternate function is chosen for a pin of this port, the bit controlling this pin should always be set.
ADE7566/ade7569/ade7166/ade7169 rev. a | page 140 of 144 table 156. port 0 alternate functions pin no. alternate function alternate function enable bctrl external battery control input set int1prog[2:0] = x01 in the interrupt pins configuration sfr (intpr, 0xff). int1 external interrupt set ex1 in the interrupt enable sfr (ie, 0xa8). p0.0 int1 wake-up from psm2 operating mode set int1prog[2:0] = 11x in the interrupt pins configuration sfr (intpr, 0xff). p0.1 fp19 lcd segment pin set fp19en in the lcd segment enable 2 sfr (lcdsege2, 0xed). p0.2 cf1 ade calibration frequency output clear the discf1 bit in the ade energy measurement internal mode1 register (0x0b). p0.3 cf2 ade calibration frequency output clear the discf2 bit in the ade energy measurement internal mode1 register (0x0b). mosi spi data line set the scps bit in the configuration sf r (cfg, 0xaf) and set the spien bit in the spi configuration sfr 2 (spimod2, 0xe9). p0.4 sdata i 2 c data line clear the scps bit in the configuration sfr (cfg, 0xaf) and set the i2cen bit in the i 2 c mode sfr (i2cmod, 0xe8). p0.5 miso spi data line set the scps bit in the configuration sf r (cfg, 0xaf) and set the spien bit in the spi configuration sfr 2 (spimod2, 0xe9). p0.6 sclk serial clock for i 2 c or spi set the i2cen bit in the i 2 c mode sfr (i2cmod, 0xe8) or the spien bit in the spi configuration sfr 2 (spimod2, 0xe9) to enable the i 2 c or spi interface. t0 timer0 input set the c/ t0 bit in the timer/counter 0 and timer/counter 1 mode sfr (tmod, 0x89) to enable t0 as an external event counter. ss spi slave select input for spi in slave mode set the ss_en bit in the spi configuration sfr 1 (spimod1, 0xe8). ss spi slave select output for spi in master mode set the spims_b bit in the spi configuration sfr 2 (spimod2, 0xe9). p0.7 t1 timer 1 input set the c/ t1 bit in the timer/counter 0 and timer/counter 1 mode sfr (tmod, 0x89) to enable t1 as an external event counter. table 157. port 1 alternate functions pin no. alternate function alternate function enable rxd receiver data input for uart set the ren bit in the seri al communications control register bit description sfr (scon, 0x98). p1.0 rx edge wake-up from psm2 operating mode set rxprog[1:0] = 11 in the peripheral configuration sfr (periph, 0xf4). p1.1 txd transmitter data output for uart this pin be comes txd as soon as data is written into sbuf. p1.2 fp25 lcd segment pin set fp25en in the lcd segment enable sfr (lcdsege, 0x97). fp24 lcd segment pin set fp24en in the lcd segment enable sfr (lcdsege, 0x97). p1.3 t2ex timer 2 control input set exen2 in the timer/counter 2 control sfr (t2con, 0xc8). fp23 lcd segment pin set fp23en in the lcd segment enable sfr (lcdsege, 0x97). p1.4 t2 timer 2 input set the c/ t2 bit in the timer/counter 2 control sfr (t2con, 0xc8) to enable t2 as an external event counter. p1.5 fp22 lcd segment pin set fp22en in the lcd segment enable sfr (lcdsege, 0x97). p1.6 fp21 lcd segment pin set fp21en in the lcd segment enable sfr (lcdsege, 0x97). p1.7 fp20 lcd segment pin set fp20en in the lcd segment enable sfr (lcdsege, 0x97). table 158. port 2 alternate functions pin no. alternate function alternate function enable p2.0 fp18 lcd segment pin set fp18en in the lcd segment enable 2 sfr (lcdsege2, 0xed). p2.1 fp17 lcd segment pin set fp17en in the lcd segment enable 2 sfr (lcdsege2, 0xed). p2.2 fp16 lcd segment pin set fp16en in the lcd segment enable 2 sfr (lcdsege2, 0xed). p2.3 sden serial download pin sampled on reset. p2.3 is an output only. enabled by default.
ADE7566/ade7569/ade7166/ade7169 rev. a | page 141 of 144 port 0 port 0 is controlled directly through the bit-addressable port 0 sfr (p0, 0x80). the weak internal pull-ups for port 0 are configured through the port 0 weak pull-up enable sfr (pinmap0, 0xb2); they are enabled by default. the weak internal pull-up is disabled by writing a 1 to pinmap0.x. port 0 pins also have various secondary functions as described in table 156 . the alternate functions of port 0 pins can be activated only if the corresponding bit latch in the port 0 sfr contains a 1. otherwise, the port pin remains at 0. port 1 port 1 is an 8-bit bidirectional port controlled directly through the bit-addressable port 1 sfr (p1, 0x90). the weak internal pull-ups for port 1 are configured through the port 1 weak pull-up enable sfr (pinmap1, 0xb3); they are enabled by default. the weak internal pull-up is disabled by writing a 1 to pinmap1.x. port 1 pins also have various secondary functions as described in table 157 . the alternate functions of port 1 pins can be activated only if the corresponding bit latch in the port 1 sfr contains a 1. otherwise, the port pin remains at 0. port 2 port 2 is a 4-bit bidirectional port controlled directly through the bit-addressable port 2 sfr (p2, 0xa0). note that p2.3 can be used as an output only. consequently, any read operation, such as a cpl p2.3, cannot be executed on this i/o. the weak internal pull-ups for port 2 are configured through the port 2 weak pull-up enable sfr (pinmap2, 0xb4); they are enabled by default. the weak internal pull-up is disabled by writing a 1 to pinmap2.x. port 2 pins also have various secondary functions as described in table 158 . the alternate functions of port 2 pins can be activated only if the corresponding bit latch in the port 2 sfr contains a 1. otherwise, the port pin remains at 0.
ADE7566/ade7569/ade7166/ade7169 rev. a | page 142 of 144 determining the version of the ADE7566/ade7569 each ADE7566/ade7569 holds in its internal flash registers a value that defines its version. this value helps to determine if users have the latest version of the part. the ADE7566/ade756 version corresponding to this datasheet is ADE7566/ade7569v3.4. to access this value, the following procedure can be followed: 1. launch hyperterminal with a 9600 baud rate. 2. put the part in serial download mode by first holding sden to logic low then resetting the part 3. hold the sden pin. 4. press and release the reset pin. 5. the following string should appear on the hyperterminal screen: ADE7566v3.4 or ade7569v3.4
ADE7566/ade7569/ade7166/ade7169 rev. a | page 143 of 144 outline dimensions compliant to jedec standards ms-026-bcd 051706-a top view (pins down) 1 16 17 33 32 48 49 64 0.27 0.22 0.17 0.50 bsc lead pitch 12.20 12.00 sq 11.80 pin 1 1.60 max 0.75 0.60 0.45 10.20 10.00 sq 9.80 view a 0.20 0.09 1.45 1.40 1.35 0.08 coplanarity view a rotated 90 ccw seating plane 0 . 1 5 0 . 0 5 7 3.5 0 figure 116. 64-lead low profile quad flat package [lqfp] (st-64-2) dimensions shown in millimeters pin 1 indicator top view 8.75 bsc sq 9.00 bsc sq 1 64 16 17 49 48 32 33 0.50 0.40 0.30 0.50 bsc 0.20 ref 12 max 0.80 max 0.65 typ 1.00 0.85 0.80 7.50 ref 0.05 max 0.02 nom 0.60 max 0.60 max * 4.85 4.70 sq 4.55 exposed pad (bottom view) * compliant to jedec standards mo-220-vmmd-4 except for exposed pad dimension 063006-b seating plane pin 1 indicator 0.30 0.25 0.18 figure 117. 64-lead lead frame chip scale package [lfcsp_vq] 9 mm x 9 mm body, very thin quad (cp-64-1) dimensions shown in millimeters
ADE7566/ade7569/ade7166/ade7169 rev. a | page 144 of 144 ordering guide model 1 anti- tamper di/dt sensor interface var flash (kb) temperature range package description package option ADE7566acpzf8 2 no no no 8 ?40c to +85c 64-lead lfcsp_vq cp-64-1 ADE7566acpzf8-rl 2 no no no 8 ?40c to +85c 64-lead lfcsp_vq, reel cp-64-1 ADE7566acpzf16 2 no no no 16 ?40c to +85c 64-lead lfcsp_vq cp-64-1 ADE7566acpzf16-rl 2 no no no 16 ?40c to +85c 64-lead lfcsp_vq, reel cp-64-1 ADE7566astzf8 2 no no no 8 ?40c to +85c 64-lead lqfp st-64-2 ADE7566astzf8-rl 2 no no no 8 ?40c to +85c 64-lead lqfp, reel st-64-2 ADE7566astzf16 2 no no no 16 ?40c to +85c 64-lead lqfp st-64-2 ADE7566astzf16-rl 2 no no no 16 ?40c to +85c 64-lead lqfp, reel st-64-2 ade7569acpzf16 2 no yes yes 16 ?40c to +85c 64-lead lfcsp_vq cp-64-1 ade7569acpzf16-rl 2 no yes yes 16 ?40c to +85c 64-lead lfcsp_vq, reel cp-64-1 ade7569astzf16 2 no yes yes 16 ?40c to +85c 64-lead lqfp st-64-2 ade7569astzf16-rl 2 no yes yes 16 ?40c to +85c 64-lead lqfp, reel st-64-2 ade7166acpzf8 2 yes no no 8 ?40c to +85c 64-lead lfcsp_vq cp-64-1 ade7166acpzf8-rl 2 yes no no 8 ?40c to +85c 64-lead lfcsp_vq, reel cp-64-1 ade7166acpzf16 2 yes no no 16 ?40c to +85c 64-lead lfcsp_vq cp-64-1 ade7166acpzf16-rl 2 yes no no 16 ?40c to +85c 64-lead lfcsp_vq, reel cp-64-1 ade7166astzf8 2 yes no no 8 ?40c to +85c 64-lead lqfp st-64-2 ade7166astzf8-rl 2 yes no no 8 ?40c to +85c 64-lead lqfp, reel st-64-2 ade7166astzf16 2 yes no no 16 ?40c to +85c 64-lead lqfp st-64-2 ade7166astzf16-rl 2 yes no no 16 ?40c to +85c 64-lead lqfp, reel st-64-2 ade7169acpzf16 2 yes yes yes 16 ?40c to +85c 64-lead lfcsp_vq cp-64-1 ade7169acpzf16-rl 2 yes yes yes 16 ?40c to +85c 64-lead lfcsp_vq, reel cp-64-1 ade7169astzf16 2 yes yes yes 16 ?40c to +85c 64-lead lqfp st-64-2 ade7169astzf16-rl 2 yes yes yes 16 ?40c to +85c 64-lead lqfp, reel st-64-2 ade8052-prg1 ade programmer ade8052z-prg1 ade programmer ade8052-dwdl1 ade downloader ade8052z- dwdl 1 ade downloader ade8052-emul1 ade emulator ade8052z-emul1 ade emulator eval- ade7169f16ebz 2 ade7169 evaluation board eval- ade7569f16ebz 2 ade7569 evaluation board 1 all models have w + va + rms, 5 v lcd, and rtc. 2 z = rohs compliant part. purchase of licensed i 2 c components of analog devices or one of its sublicensed associated companies conveys a license for the purchaser under the phi lips i 2 c patent rights to use these components in an i 2 c system, provided that the system conforms to the i 2 c standard specification as defined by philips. ?2007 analog devices, inc. all rights reserved. trademarks and registered trademarks are the property of their respective owners. d06353-0-12/07(a)


▲Up To Search▲   

 
Price & Availability of ADE7566

All Rights Reserved © IC-ON-LINE 2003 - 2022  

[Add Bookmark] [Contact Us] [Link exchange] [Privacy policy]
Mirror Sites :  [www.datasheet.hk]   [www.maxim4u.com]  [www.ic-on-line.cn] [www.ic-on-line.com] [www.ic-on-line.net] [www.alldatasheet.com.cn] [www.gdcy.com]  [www.gdcy.net]


 . . . . .
  We use cookies to deliver the best possible web experience and assist with our advertising efforts. By continuing to use this site, you consent to the use of cookies. For more information on cookies, please take a look at our Privacy Policy. X